From:             a dot bendilas at zefxis dot gr
Operating system: WinXP SP2
PHP version:      4.3.8
PHP Bug Type:     Strings related
Bug description:  strpos doesn't work as it should

Description:
------------
Although strpos returns the position of the needle correctly, when testing
the return value with a boolean operator to see if it's true, it produces
the opposite result.

Reproduce code:
---------------
$string = 'Once upon a time in America';
$srchstring = 'time';
$position = strpos($string, $srchstring);

echo 'String: '.$string.'<br />';
echo 'Search string: '.$srchstring.'<br />';
echo 'Position of search string: '.$position.'<br />';

if ((strpos($string, $srchstring) === true)) echo 'Search string is
included in the original string!'; else echo 'Search string is not
included in the original string!';


Expected result:
----------------
Search string is included in the original string!

Actual result:
--------------
Search string is not included in the original string!

-- 
Edit bug report at http://bugs.php.net/?id=30158&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=30158&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30158&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30158&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=30158&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=30158&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=30158&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=30158&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=30158&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=30158&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=30158&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=30158&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=30158&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=30158&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=30158&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=30158&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=30158&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=30158&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=30158&r=float
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=30158&r=mysqlcfg

Reply via email to