Below is a function I've written for validating URLs.
function isURL ($string, $fieldname)
{
if(preg_match("/^[http://www.|www.][\S]+$/", $string))
{
return TRUE;
}
else
{
$this->number_of_erro rs++;
$this->error_message_ list[]="The " .$fieldname. " is not a valid URL.";
return FALSE;
}
}
However I keep getting the error message:
Warning: preg_match() [function.preg-match]: Unknown modifier '/'
This is the code that I call it:
if ($testValidate->isURL($testStr ing11,"String 11"))
{
echo "The string <b>".$testStrin g11."</bpassed.";
}
else
{
echo "The string <b>".$testStrin g11."</bfailed.";
}
What have I obviously missed?
Cheers
Phil
function isURL ($string, $fieldname)
{
if(preg_match("/^[http://www.|www.][\S]+$/", $string))
{
return TRUE;
}
else
{
$this->number_of_erro rs++;
$this->error_message_ list[]="The " .$fieldname. " is not a valid URL.";
return FALSE;
}
}
However I keep getting the error message:
Warning: preg_match() [function.preg-match]: Unknown modifier '/'
This is the code that I call it:
if ($testValidate->isURL($testStr ing11,"String 11"))
{
echo "The string <b>".$testStrin g11."</bpassed.";
}
else
{
echo "The string <b>".$testStrin g11."</bfailed.";
}
What have I obviously missed?
Cheers
Phil
Comment