Jump to content

[SOLVED] Disallow certain characters from a field


webref.eu

Recommended Posts

The easiest way i can think of right now, should be:

 

<?php
$str = 'phpfreaks@';
if(strpos($str, '@')){ //you can do this for all the other characters using OR strpos($str, '<') and so on
     echo '@ found';
}
?>

 

but im sure there are fancier ways.

stristr() is the case-insensitive strstr(), where in the manual it is stated:

 

Note: If you only want to determine if a particular needle occurs within haystack , use the faster and less memory intensive function strpos() instead.

 

Not that it will make a lot of difference, but just to let you know.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.