Q: Logical assignment with strstr( )

From: Date: Fri, 23 Feb 2007 11:24:33 +0000
Subject: Q: Logical assignment with strstr( )
Groups: php.general 
Request: Send a blank email to php-general+get-249277@lists.php.net to get a copy of this message
Dear list, strstr returns a string (in case the needle is found), but a boolean if there is no needle in the haystack. I am trying to make a readable evaluation of some tests, but this fails to work as supposed because of - undefined results when "OR"ing strings with possible string (?) - use of bitwise OR operator ("|") where I am uncertain if I can write anything like $a ||= $b; Please read this snippet and tell me your ideas ;) Thanks Ralf $oLen = strlen ($commentary); $isSpam = ! strstr($_POST['Name']," "); $isSpam |= strlen (str_replace("http://","",$commentary)) < $oLen; $isSpam |= strstr($_POST['Name'],"@"); $isSpam |= stristr($_POST['Name'],"Casino"); //My next trial will be to add "is_string( ...)"

« previous php.general (#249277) next »