#29977 [Opn->Bgs]: bool cast of "0000000000000"
| From: | vrana@php.net | Date: | Mon, 14 Mar 2005 08:13:08 +0000 |
| Subject: | #29977 [Opn->Bgs]: bool cast of "0000000000000" | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969366962@lists.php.net to get a copy of this message | ||
ID: 29977
Updated by: vrana@php.net
Reported By: hd dot php at aimail dot de
-Status: Open
+Status: Bogus
Bug Type: Documentation problem
Operating System: linux
PHP Version: 4.3.10 / 5+
New Comment:
Already documented at http://php.net/language.types.boolean: "When
converting to boolean, the following values are considered FALSE: ...
the empty string, and the string "0" ... Every other value is
considered TRUE."
Previous Comments:
------------------------------------------------------------------------
[2005-03-14 08:46:21] mail at etarion dot de
Well, it is documented. In the type juggling section it is said that
the only strings evaluating to false are "" and "0".
------------------------------------------------------------------------
[2005-03-13 21:46:03] sniper@php.net
Document it.
------------------------------------------------------------------------
[2004-09-05 10:04:55] aidan@php.net
"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");'
------------------------------------------------------------------------
[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