Page 2 of 2
Posted: Sun Feb 04, 2007 6:07 pm
by SmokyBarnable
That is only the case when it is a equality comparison to boolean, but there are many types of equality comparison in PHP.
Then how do you explain this?
Code: Select all
<?php
$result = var_dump((bool) 1);
echo $result;
$result = var_dump((bool) 0);
echo $result;
?>
Posted: Sun Feb 04, 2007 6:18 pm
by bokehman
SmokyBarnable wrote:Then how do you explain this?
Are you on a wind-up? Of 0 will equal false if you convert it to a boolean first but I don't see the connection between that and my comment that there are many types of equality comparison in PHP.
Posted: Sun Feb 04, 2007 6:25 pm
by SmokyBarnable
I don't see the connection between that and my comment that there are many types of equality comparison in PHP.
I don't understand where the equality comparison is in this statment.
Posted: Sun Feb 04, 2007 6:32 pm
by bokehman
Unbalanced conditionals do an equality comparison to boolean.
Posted: Sun Feb 04, 2007 6:48 pm
by SmokyBarnable
I see. So even if zero equates to false I shouldn't assume that it always will?
Posted: Sun Feb 04, 2007 7:01 pm
by bokehman
It only evalutes to false when checked as a boolean. If you start checking against other types you will get different results.
Posted: Sun Feb 04, 2007 7:03 pm
by SmokyBarnable
got it.
thanks for your help.
Posted: Mon Feb 05, 2007 1:08 am
by jmut