note 16177 added to function.strpos
| From: | meheler at searchbc dot com | Date: | Thu, 18 Oct 2001 21:09:25 +0000 |
| Subject: | note 16177 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-19109@lists.php.net to get a copy of this message | ||
Quite the contrary, mfrazer@udel.edu, the example you provided does not print String Found:
<?php
$test = strpos("test string", "test");
if ($test) { print "String Found"; }
else { print "String not found"; }
?>
Output:
String not found.
Using the same method, but searching for "string", which occurs at position 5 of the
string:
<?php
$test = strpos("test string", "string");
if ($test) { print "String Found"; }
else { print "String not found"; }
?>
Output:
String Found
The same first demo, but altered to work, note the '!==':
<?php
$test = strpos("test string", "test");
if ($test !== FALSE) { print "String Found"; }
else { print "String not found"; }
?>
Output:
String Found
--
http://www.php.net/manual/en/function.strpos.php
http://master.php.net/manage/user-notes.php?action=edit+16177
http://master.php.net/manage/user-notes.php?action=delete+16177
http://master.php.net/manage/user-notes.php?action=reject+16177