What am i doing wrong :\
| From: | Clivus2k1 at aol dot com | Date: | Mon, 12 May 2003 17:25:23 +0000 |
| Subject: | What am i doing wrong :\ | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-147323@lists.php.net to get a copy of this message | ||
Basicly its a simple to check to see if chars a-z,A-Z,0-9 and _ are added,
why does this tell me both strings display illegal chars? :\
<?
function validc($text) {
if (preg_match("[a-zA-Z0-9_]",$text)) { return 1; }
else { return 0; }
}
$str = "moo-";
if (!validc($str)) { echo("ERROR - $str contains illegal chars<br>"); }
$str2 = "moo";
if (!validc($str2)) { echo("ERROR - $str2 contains illegal chars"); }
?>
Thanks for the help in advanced :-)