|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2011-01-01 15:49 UTC] jani@php.net
 
-Summary:          logic error in boolean cast from
                   string
+Summary:          Logic error in boolean cast from
                   string
-Package:          Feature/Change Request
+Package:          Scripting Engine problem
-Operating System: Ubuntu 9.04
+Operating System: *
-PHP Version:      5.3.0
+PHP Version:      *
  [2016-12-19 09:03 UTC] miklcct at gmail dot com
  [2016-12-19 09:26 UTC] requinix@php.net
 
-Status: Open
+Status: Wont fix
  [2016-12-19 09:26 UTC] requinix@php.net
 | |||||||||||||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 11:00:01 2025 UTC | 
Description: ------------ When you cast a string variable to boolean type there are some cases in which the cast doesn't work properly, i think. Reproduce code: --------------- $arrTestVars = array( '0', '-0', '+0', '0.0', '0e0', '0.0e0' ); foreach($arrTestVars as $strTestVar) { var_dump( (bool)$strTestVar ); } Expected result: ---------------- // Expected Result => (bool)false, (bool)false, (bool)false, (bool)false, (bool)false, (bool)false All the tests above should be evaluated to false, because (bool)0.0 === false (bool)0e0 === false and so on. Now one has to use the workaround (bool)(int)'0.0' === false ... Actual result: -------------- // Actual Result => (bool)false, (bool)true, (bool)true, (bool)true, (bool)true, (bool)true