note 16177 deleted from function.strpos by jimw
| From: | jimw@php.net | Date: | Fri, 14 Dec 2001 20:06:03 +0000 |
| Subject: | note 16177 deleted from function.strpos by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22700@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