[EMAIL PROTECTED] ("Jay Blanchard") writes:

> In certain cases 0 is the equivalent of FALSE and in other cases a 0 is
> just a 0... Exercise care when using 0 to determine if something is FALSE
> and understand that 0 has context.

     I think "context" and "equivalence" are not completely accurate way to
think about this.

     0 is always 0.

     0 is equal to ( == ) False. 0 is not identical to ( !== ) False. If 0
needs to be typecast or converted to a boolean value, the result is False.

     Saying that it's the "equivalent of" False is ambiguous. AFAIK
"equivalent" is not a PHP operator or concept. When you say
"equivalent" do you mean "equal to" or "identical to" or "gets cast to" or
something else? 

     PHP programmers must understand the difference between "x equals y"
and "x is identical to y", and the implicit type conversions that occur.
Novices, study

http://www.php.net/manual/en/language.operators.comparison.php

http://www.php.net/manual/en/language.types.type-juggling.php

until you grok why

<?php

if (0 == False) echo "0 == False\n";
if (1 == True) echo "1 == True\n";
if (-1 == True) echo "-1 == True\n";

$b = (boolean)-1; var_dump($b);
$i = intval($b); var_dump($i);

?>

gives

0 == False
1 == True
-1 == True
bool(true)
int(1)


-- Tom Swiss / tms(at)infamous.net / www.infamous.net / www.unreasonable.org
    "What's so funny about peace, love, and understanding?" - Nick Lowe
                  "Power to the Peaceful" - Michael Franti




     

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to