Bug #70132 [Opn->Csd]: bit(1) always seen as true

From: Date: Tue, 02 Mar 2021 13:35:13 +0000
Subject: Bug #70132 [Opn->Csd]: bit(1) always seen as true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-232475@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70132&edit=1 ID: 70132 Updated by: cmb@php.net Reported by: stanimir at datacentrix dot org Summary: bit(1) always seen as true -Status: Open +Status: Closed Type: Bug Package: PDO MySQL Operating System: linux PHP Version: 5.6.11 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Indeed, casting a string with a NUL byte to bool is supposed to return true. No issue here. Anyhow, it appears this issue has been fixed in the meantime. With emulated prepares, I get string(1) "0" and string(1) "1", respectively, and without emulated prepares I get int(0)/int(1). So casting to bool yields the desired result. Previous Comments: ------------------------------------------------------------------------ [2015-07-30 20:22:25] cmb@php.net Related To: Bug #70170 ------------------------------------------------------------------------ [2015-07-25 21:45:39] fontanalorenz at gmail dot com AFAIK the expected result is true because when 0x00 is converted by chr gives you a one char string so when you cast to bool it returns true; To verify that you can just do <?php $chr = chr(0x00); var_dump((bool)$chr); // bool(true) var_dump(strlen($chr)); // int(1) ------------------------------------------------------------------------ [2015-07-24 16:56:43] stanimir at datacentrix dot org Description: ------------ Using MySQL 5.5.44, BIT(1) column returns either 0x00 or 0x01, both are considered as true by the language. Test script: --------------- var_dump((bool) chr(0x00)); Expected result: ---------------- boolean false Actual result: -------------- boolean true ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70132&edit=1

« previous php.bugs (#232475) next »