Bug #1540 Updated: strpos(): returning FALSE or 0 is the same

From: Date: Tue, 15 Jun 1999 13:24:10 +0000
Subject: Bug #1540 Updated: strpos(): returning FALSE or 0 is the same
Groups: php.dev 
Request: Send a blank email to php-dev+get-6986@lists.php.net to get a copy of this message
ID: 1540 Updated by: cmv Reported By: a.suatoni@itaca.it Status: Closed Bug Type: Misbehaving function Assigned To: cmv Comments: Actually, Rasmus said: "No, the two things actually return different things. 0 is returned if the char is found at position 0 and '' (a null string) is returned if the char is not found at all. Granted, both evaluate to FALSE in a conditional which is the source of the problem." So, the function works as documented. Basically, you're using the wrong function. Try strstr(): <? if (strstr("abcde","a")) { echo "it's in there"; } else { echo "it's not"; } ?> Full Bug description available at: http://bugs.php.net/?id=1540

« previous php.dev (#6986) next »