note 53913 deleted from function.strpos by sean

From: Date: Thu, 16 Jun 2005 19:35:35 +0000
Subject: note 53913 deleted from function.strpos by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-90554@lists.php.net to get a copy of this message
Note Submitter: matt at braynard dot com Reason: bad code ---- You can only use === to test for false. If you try to evaluate TRUE, it will return ELSE or NOTHING. See below: // This works: $mystring = 'abcdefg'; $findme = 'a'; $pos = strpos($mystring, $findme); if ($pos === false) { echo "Does not Exist!" ; }else{ echo "True!!" ; } // But THIS does not: $mystring = 'abcdefg'; $findme = 'a'; $pos = strpos($mystring, $findme); if ($pos === true) { echo "True!!" ; }else{ echo "Does not Exist!" ; }

« previous php.notes (#90554) next »