php - Trying to eliminate a character -
$message=$this->filter($_post['suggestion']); protected function filter($mail) { if(strpos($mail,"<") !== false) { $mail = "message entered invalid"; } else { $mail = $mail; } return $mail; }
sure i'm doing wrong here, if $_post["suggestion"]
contains "<" should return predefined message. doesn't work: return same message regardless if "<" in there or not.
you use preg_match
function filter($mail) { if(preg_match("/</", $mail)) { $mail="message entered invalid"; } return $mail; }
Comments
Post a Comment