php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39338 Unexpected answer from if statement dealing with zeros.
Submitted: 2006-11-01 20:39 UTC Modified: 2006-11-08 14:09 UTC
From: spideybr at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.4.4 OS: Ubuntu 4
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: spideybr at gmail dot com
New email:
PHP Version: OS:

 

 [2006-11-01 20:39 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-02 07:15 UTC] 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-08 14:09 UTC] tony2001@php.net
.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 19 23:00:03 2025 UTC