This is the problem I am working on:
Write a PHP function called isValidLNumber that takes one parameter that represents a string that represents an LCC Lnumber and a second reference parameter that will store the error message generated inside the function. The function should return true if the LNumber is valid and false if it is not. In order to be valid, an LNumber must be provided and must match the pattern L######## or l######## where # represents a digit.

Test your function by calling it with an empty string, an invalid LNumber, and a valid LNumber. Make sure you display both the return value and the error message when testing your function.

I have this so far, but, it is not correct, specially the !preg_match.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scholarship Form</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
function isValid($number, &$errorMessage)
{
if (empty($number))
{
$errorMessage = "Enter something.";
return false;
}
else if ($number != intval($number))
{
$errorMessage = "Enter an integer.";
return false;
}
else if ($number < 3 || $number > 1000)
{
$errorMessage = "Enter a number between 3 and 1000";
return false;
}
else
return true;
}


function isValidLNumber($LNumber, &$errorMessage)
{
if (empty($LNumber))
{
$errorMessage = "Enter something.";
return false;
}
else if (!preg_match("/^\d{3}-\d{2}-\d{4}$/", $ssn))
{
$errorMessage = "Enter an LNumber in the format L######## or l########.";
return false;
}
else
return true;
}
?>