ID: 15201
Updated by: derick
Old Summary: ('foo'==0) => equal ?
Reported By: [EMAIL PROTECTED]
Old Status: Open
Status: Bogus
Bug Type: Variables related
Operating System: i688-gnu-linux
PHP Version: 4.0CVS-2002-01-24
New Comment:

It's indeed due to automatic conversion. The vars get converted to
ints, and the integer value of 'foo' = 0
Use if ($a === $b) to check for both value and type.

Derick


Previous Comments:
------------------------------------------------------------------------

[2002-01-24 06:15:26] [EMAIL PROTECTED]

A simple condition with a strange result:


<?php
$a='foo';
$b=0;
if ($a==$b) echo 'equal';
else echo 'not equal';
?>

result: $a and $b is equal,
but if $b unequal zero
the condition results 'not equal'

This is not really rationally.

Is the problem the automatic type casting?


Regards,

Steve

------------------------------------------------------------------------



Edit this bug report at http://bugs.php.net/?id=15201&edit=1


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to