#39338 [Com]: Unexpected answer from if statement dealing with zeros.
ID: 39338
Comment by: judas dot iscariote at gmail dot com
Reported By: spideybr at gmail dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Ubuntu 4
PHP Version: 4.4.4
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
Use the === operator, this is the expected behaviour.
Previous Comments:
------------------------------------------------------------------------
[2006-11-01 20:39:03] spideybr at gmail dot com
Description:
------------
I've got a "GET variable" called $codArea in my script. Just before the
if statement an echo on the variable would return me "asd" (just to test
it, the normal would be integers btw). Inside the { } in the if
structure, it also echo's "asd".
The problem is, the statement which is returning TRUE (so the script
goes inside de if brackets) is ' $codArea == 0 ' without the single
quotes. Just look in the code and you'll understand. Not a type
conversion misusage, I guess.
Reproduce code:
---------------
//script.php?area=asd on the address bar and on links
$codArea = $_GET['area']; //Creating the "GET variable"
echo $codArea; // returns "asd"
if ($codArea == 0) {
echo $codArea; // returns "asd"
echo ($codArea == 0); // returns "1"
}
//All values are printed on the screen without the quotes
Expected result:
----------------
asd
Actual result:
--------------
asd
asd
1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=39338&edit=1
Thread (3 messages)