#29977 [Bgs->Opn]: bool cast of "0000000000000"
| From: | aidan@php.net | Date: | Sun, 05 Sep 2004 08:04:56 +0000 |
| Subject: | #29977 [Bgs->Opn]: bool cast of "0000000000000" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-65748@lists.php.net to get a copy of this message | ||
ID: 29977
Updated by: aidan@php.net
Reported By: hd dot php at aimail dot de
-Status: Bogus
+Status: Open
Bug Type: Feature/Change Request
Operating System: linux
PHP Version: 4.3.7
New Comment:
"00" is a string, like any other string. The only other string that
will evaluate to false is "0".
This may, however, be something we should fix, and at the very least
document - what do others think?
TRUE: $ php -r 'var_dump((bool)"00");'
FALSE: $ php -r 'var_dump((bool)"0");'
Previous Comments:
------------------------------------------------------------------------
[2004-09-05 10:03:54] aidan@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
"00" is a string, like any other string. The only other string that
will evaluate to false is "0".
This may, however, be something we should fix, and at the very least
document - what do others think?
------------------------------------------------------------------------
[2004-09-04 01:22:36] hd dot php at aimail dot de
Description:
------------
* PHP Version 4.3.4 *
bool cast of "0000000000000" should be false, not true.
A "0000000000000" is returned from mysql timestamp fields.
(bool)"0000000000000"
should be consistent with
(bool)(int)"0000000000000"
At this point it is not.
Reproduce code:
---------------
<?
echo((bool)"0000000000000"?"true":"false");
?>
Expected result:
----------------
false
Actual result:
--------------
true
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29977&edit=1