#39338 [NEW]: Unexpected answer from if statement dealing with zeros.
| From: | spideybr at gmail dot com | Date: | Wed, 01 Nov 2006 20:39:03 +0000 |
| Subject: | #39338 [NEW]: Unexpected answer from if statement dealing with zeros. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-104265@lists.php.net to get a copy of this message | ||
From: spideybr at gmail dot com
Operating system: Ubuntu 4
PHP version: 4.4.4
PHP Bug Type: Scripting Engine problem
Bug description: Unexpected answer from if statement dealing with zeros.
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 bug report at http://bugs.php.net/?id=39338&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39338&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39338&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39338&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39338&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39338&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39338&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39338&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39338&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39338&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39338&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39338&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39338&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39338&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39338&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39338&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39338&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39338&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39338&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39338&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39338&r=mysqlcfg