Edit report at http://bugs.php.net/bug.php?id=53094&edit=1

 ID:                 53094
 Updated by:         ras...@php.net
 Reported by:        php-bugs at majkl578 dot cz
 Summary:            Use '0' instead of '' as a result of converting
                     boolean FALSE to string
-Status:             Open
+Status:             Bogus
 Type:               Feature/Change Request
 Package:            Scripting Engine problem
 Operating System:   Irrelevant
 PHP Version:        Irrelevant
 Block user comment: N

 New Comment:

This would be extremely counterintuitive to most people since every
language I 

know will return a zero-length string when boolean false is converted to
a string.  

Having it return a non-zero length string would cause all sorts of
backward 

compatibility problems as well.


Previous Comments:
------------------------------------------------------------------------
[2010-10-18 10:30:42] php-bugs at majkl578 dot cz

Description:
------------
I'd like to propose a change in converting booleans to string.

It'd be better if (string) FALSE returns '0' instead of empty string
('').

Why to do so?

 a) More logical behavior.

 b) Using booleans in output would be meaningful.

 c) Backward-compatible change - as documentation says: "This allows
conversion back and forth between boolean and string values." - this
behavior is not changed by this, because (bool) '0' is FALSE.

Test script:
---------------
<?php



echo (string) FALSE; //nothing now, '0' requested

var_dump((bool) '0'); //FALSE, no change

var_dump((string) FALSE === '0'); //FALSE, TRUE requested



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53094&edit=1

Reply via email to