From: rbotzer at yahoo dot com
Operating system: MacOS X
PHP version: 4.3.3
PHP Bug Type: Feature/Change Request
Bug description: string false type-casts into boolean TRUE
Description:
------------
When I type-cast the string "false" into a boolean it evaluates to TRUE.
This is non-sensical. Can we please change the type-casting so that it
evaluates as FALSE.
Thanks,
Ronen Botzer
Reproduce code:
---------------
<?php
// start example:
$x = "false";
if ($x === "false") {
print ("the string value of x is evaluating as \"false\" \n");
var_dump ($x);
print ("\n");
}
$y = (boolean) $x;
print ("\$x was type-cast into boolean \$y\n\n");
if ($y) {
print ("the boolean value of x is evaluating as true\n");
var_dump ($y);
}
// end example
?>
Expected result:
----------------
I expect to only see a printout from the first conditional. The second
should evaluate as false, and not print.
Actual result:
--------------
the string value of x is evaluating as "false"
string(5) "false"
$x was type-cast into boolean $y
the boolean value of x is evaluating as true
bool(true)
--
Edit bug report at http://bugs.php.net/?id=25734&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=25734&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=25734&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=25734&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=25734&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=25734&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=25734&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=25734&r=support
Expected behavior: http://bugs.php.net/fix.php?id=25734&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=25734&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=25734&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=25734&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=25734&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=25734&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=25734&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=25734&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=25734&r=float