#39338 [Opn->Bgs]: Unexpected answer from if statement dealing with zeros.

From: Date: Wed, 08 Nov 2006 14:09:28 +0000
Subject: #39338 [Opn->Bgs]: Unexpected answer from if statement dealing with zeros.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-104589@lists.php.net to get a copy of this message
ID: 39338 Updated by: tony2001@php.net Reported By: spideybr at gmail dot com -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Ubuntu 4 PHP Version: 4.4.4 New Comment: . Previous Comments: ------------------------------------------------------------------------ [2006-11-02 07:15:37] judas dot iscariote at gmail dot com 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#104589) next »