note 15282 added to function.strpos

From: Date: Tue, 04 Sep 2001 15:45:48 +0000
Subject: note 15282 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-17609@lists.php.net to get a copy of this message
There is an insanely easy way to test for no match: $test = strpos("test string", "test"); if ($test) { print "String Found"; } else { print "String not found"; } The return value for strpos() is an integer which is zero-based. If it doesn't find a match, it returns an empty integer (NOT zero). Try telling it to find something that you know won't find a match and then print the return value: nothing prints, therefor the return value is undefined. You're creating a lot more work for you and the server by doing all those other tests. http://www.php.net/manual/en/function.strpos.php

« previous php.notes (#17609) next »