#39904 [Com]: string -> boolean conversion of "\0" could give FALSE

From: Date: Fri, 17 Apr 2009 23:56:48 +0000
Subject: #39904 [Com]: string -> boolean conversion of "\0" could give FALSE
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135942@lists.php.net to get a copy of this message
ID: 39904 Comment by: dave at ifox dot com Reported By: zizka at seznam dot cz Status: Open Bug Type: Feature/Change Request PHP Version: 5.2.0 New Comment: This is by far the worst thing that has found itself into PHP. Previous Comments: ------------------------------------------------------------------------ [2006-12-20 14:46:44] zizka at seznam dot cz 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 this bug report at http://bugs.php.net/?id=39904&edit=1

« previous php.bugs (#135942) next »