#35041 [Bgs-Csd]: if (strpos(123,1)===true) doesn't work. if (strpos(123,1)!==false) does

2005-11-01 Thread john dot clements at publicinfo dot net
 ID:   35041
 User updated by:  john dot clements at publicinfo dot net
 Reported By:  john dot clements at publicinfo dot net
-Status:   Bogus
+Status:   Closed
 Bug Type: Strings related
 Operating System: Windows xp pro sp2
 PHP Version:  5CVS-2005-10-31 (snap)
 New Comment:

I reported this as a documentation issue using the web form found from
the manual. The response was to report it as a bug. So I did. Now I
will go back and report it again as a documentation issue and submit my
own documentation comment.


Previous Comments:


[2005-11-01 07:36:31] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

strpos doesn\'t return true on success but the position  



[2005-11-01 00:12:28] john dot clements at publicinfo dot net

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 this bug report at http://bugs.php.net/?id=35041edit=1


#35041 [NEW]: if (strpos(123,1)===true) doesn't work. if (strpos(123,1)!==false) does

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