millercj Posted March 22, 2008 Share Posted March 22, 2008 Hi everyone, I'm having some issues with a script. I want it to examine a string and simply report a true/false whether there are special characters in the string. I found an example on line and tried to adapt it to what i'm tryig to do but no matter the input it is spitting out a 0 This is what i have <?PHP $input=$_POST['input']; $review = preg_match('/!@#$%^&*()/',$input); echo $review; ?> Link to comment https://forums.phpfreaks.com/topic/97310-special-characters/ Share on other sites More sharing options...
marun Posted March 22, 2008 Share Posted March 22, 2008 Yuo should change your regexp: $review = preg_match('/[!@#$%^&*()]/', $input); This will match when any of '!@#$%^&*()' will be present at $input. Link to comment https://forums.phpfreaks.com/topic/97310-special-characters/#findComment-498020 Share on other sites More sharing options...
millercj Posted March 22, 2008 Author Share Posted March 22, 2008 Thanks! it worked great Link to comment https://forums.phpfreaks.com/topic/97310-special-characters/#findComment-498036 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.