Re: Is this a PHP bug?

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

 



Ross Honniball wrote:

$x = 0; // Numeric zero
$y = 'Some kind of string';

if ($x == $y) echo 'they equal using ==';
if ($x === $y) echo 'they equal using ===';

The above will echo 'they equal using =='.

The values don't look very equal to me.

Can anyone explain the logic behind this?

I'm heading home now but look forward to your explanations tomorrow.

PS

Incidently, to 'fix' it so it behaves as it should, you can code:

if ($x.'' == $y.'') echo 'this will not print and all is good.';

Regards .. Ross


there is some stuff about it here: http://us2.php.net/manual/en/language.types.boolean.php

sorry if this posted twice :p

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux