#39579 [Opn->Bgs]: Comparing zero & string values in boolean comparison has unexpected behaviour
From: derick@php.net Date: Wed, 22 Nov 2006 08:17:02 +0000 Subject: #39579 [Opn->Bgs]: Comparing zero & string values in boolean comparison has unexpected behaviour References: 1 Groups: php.bugs Request: Send a blank email to php-bugs+get-105283@lists.php.net to get a copy of this message
ID: 39579
Updated by: derick@php.net
Reported By: iain at workingsoftware dot com dot au
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: FreeBSD 6.1
PHP Version: 5.2.0
New Comment:
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
.
Previous Comments:
------------------------------------------------------------------------
[2006-11-22 07:31:34] iain at workingsoftware dot com dot au
Description:
------------
if you have a variable with the value 0 assigned to it and do a
comparison with a non-integer then the non-integer value is cast to an
int with unexpected results. it behaves differently when comparing a
non-zero integer.
Reproduce code:
---------------
put this in test.php and run php -f test.php:
<?php
$zero = 0;
$one = 1;
if($zero == 'SOME STRING')
echo("0 does equal 'SOME STRING'\n");
else
echo("0 does not equal 'SOME STRING'\n");
if($one == 'SOME STRING')
echo("1 does equal 'SOME STRING'\n");
else
echo("1 does not equal 'SOME STRING'\n");
?>
Expected result:
----------------
0 does not equal 'SOME STRING'
1 does not equal 'SOME STRING'
Actual result:
--------------
0 does equal 'SOME STRING'
1 does not equal 'SOME STRING'
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39579&edit=1
Thread (29 messages)
- #39579 [Opn->Bgs]: Comparing zero & string values in boolean comparison has unexpected behaviour
- #39579 [Bgs->Opn]: Comparing zero & string values in boolean comparison has unexpected behaviour
- #39579 [Opn->Bgs]: Comparing zero & string values in boolean comparison has unexpected behaviour
- #39579 [Bgs]: Comparing zero & string values in boolean comparison has unexpected behaviour
- #39579 [Bgs]: Comparing zero & string values in boolean comparison has unexpected behaviour
- #39579 [Bgs]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Bug #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Bug #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Bug #39579 [Nab]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Bug #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Bug #39579 [Nab]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Bug->Req #39579 [Nab]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Nab]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Nab]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Nab]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Com]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Nab]: Comparing zero & string values in boolean comparison has unexpected behaviour
- Req #39579 [Nab]: Comparing zero & string values in boolean comparison has unexpected behaviour
| « previous | php.bugs (#105283) | next » |
|---|