You are here: preg_match function for URLs « PHP Programming Language « IT news, forums, messages
preg_match function for URLs

Posted by Phil Latio on 06/20/07 03:47

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_errors++;
$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($testString11,"String 11"))
{
echo "The string <b>".$testString11."</b> passed.";
}
else
{
echo "The string <b>".$testString11."</b> failed.";
}

What have I obviously missed?

Cheers

Phil

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация