Re: Re: Comparison Operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jason Morehouse wrote:

Russell Chadwick wrote:

Could anyone tell me why this code echos?
<?php
$value = 0;
$curval = 'A';
if ($value == $curval) {
echo "WTH, Over<br>";
}
?>


$value = 0 means false. And your comparison is false. Try:

If the comparison is false, the echo shouldn't be executed.

This if statement is evaluating to true, because...

"If you compare an integer with a string, the string is converted to a number."

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

<snip>

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
john@xxxxxxxxxxxx

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux