ID: 25740
Updated by: [EMAIL PROTECTED]
Reported By: daijoubu at videotron dot ca
-Status: Open
+Status: Bogus
Bug Type: Strings related
Operating System: Win98SE
PHP Version: 4.3.3
New Comment:
from the manual page for strstr():
"Returns part of haystack string from the first occurrence of needle to
the end of haystack."
strstr() works just fine, the last char in your string is '0' (zero).
Try this:
<?php
$test = '1234567890';
var_dump(strstr($test, '0'));
?>
# php test.php
string(1) "0"
You see it's string, it's not boolean.
To get reliable results, always check the type of returned
variable. Like this:
<?php
$test = '1234567890';
if (strstr($test, '0') !== false) {
$result = 1;
}
?>
Previous Comments:
------------------------------------------------------------------------
[2003-10-03 01:49:53] daijoubu at videotron dot ca
Description:
------------
string strstr ( string haystack, string needle)
If needle is numeric and lenght of 1 at the end of the haystack,
returns false
No problem if needle is 'a' ($test = '123456789a') or '90' ($test =
'1234567890')
Reproduce code:
---------------
$test = '1234567890';
if (strstr($test, '0'))
{
$result = 1;
}
Expected result:
----------------
result = 1;
Should output the same as:
if (strpos($test, '0') !== false)
{
$result = 1;
}
Actual result:
--------------
$result = 0;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25740&edit=1