note 53913 added to function.strpos
| From: | matt at braynard dot com | Date: | Thu, 16 Jun 2005 19:03:07 +0000 |
| Subject: | note 53913 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-90553@lists.php.net to get a copy of this message | ||
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!" ;
}
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+53913
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53913&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53913&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53913&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53913&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+53913&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53913&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+53913&report=yes
Search -- http://master.php.net/manage/user-notes.php