From:             john dot clements at publicinfo dot net
Operating system: Windows xp pro sp2
PHP version:      5CVS-2005-10-31 (snap)
PHP Bug Type:     Strings related
Bug description:  if (strpos("123","1")===true) doesn't work. if 
(strpos("123","1")!==false) does

Description:
------------
This is a problem with === true and !== true whether used with strpos or
with array_search and presumably with other functions.

This also fails under PHP 4.3.10 on FreeBSD 4.8-STABLE,
but that is a hosted server and I can't upgrade it to test.

I have done further testing and found that 
checking for === false or !== false is OK:
=== false works when statement is true
=== false works when statement is false
=== true doesn't work when statement is true
=== true works when statement is false
!== true  doesn't work when statement is true
!== true  works when statement is false
!== false works when statement is true
!== false works when statement is false
Pls get in touch if you would like the code to show that. 


Reproduce code:
---------------
<?php

if (strpos("hey","h") === true) print "1. worked \n";
else print "1. didn't work\n";
if (strpos("hey","h") !== false) print "2. worked \n";
else print "2. didn't work\n";
?>


Expected result:
----------------
1. worked
2. worked


Actual result:
--------------
1. didn't work
2. worked


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

Reply via email to