From:             zizka at seznam dot cz
Operating system: 
PHP version:      5.2.0
PHP Bug Type:     Feature/Change Request
Bug description:  string -> boolean conversion of "\0" could give FALSE

Description:
------------
It might be useful that (boolean)"\0" would give FALSE.
E.g. MySQL's BIT(1) column type can be used to store boolean values, but
now PHP converts whatever value to TRUE.

Reproduce code:
---------------
header('Content-Type: text/plain');

echo "\nfalse: ".ord(false);
echo "\ntrue: ".ord(true);
echo "\n\\0: ".(boolean)("\0");
echo "\n\\1: ".(boolean)("\1");

// ord() is here just for thoughts context...

Expected result:
----------------
false: 0
true: 49
\0: 0
\1: 1

Actual result:
--------------
false: 0
true: 49
\0: 1  <----- HERE
\1: 1

-- 
Edit bug report at http://bugs.php.net/?id=39904&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39904&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39904&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39904&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39904&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39904&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39904&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39904&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39904&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39904&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39904&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39904&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39904&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39904&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39904&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39904&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39904&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39904&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39904&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39904&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39904&r=mysqlcfg

Reply via email to