From:             philipp at bind dot ch
Operating system: Linux
PHP version:      Irrelevant
PHP Bug Type:     *General Issues
Bug description:  'if' bug

Description:
------------
hi there!

I'll past some code here to explain my problem.
I dont know if it is a bug or not bug it looks like one to me!

I had some real ugly problems because of this.
If you have a look at the output of this code you'll see what i mean!
if php commpares 0 with any string the if function tells us that this is
true.

I cant believe that the language should be like that so I wrote this
bug-report.



Reproduce code:
---------------
$test_char = 'a';
$my_array = array(0, 1, '0', '1', 'a', 'b');
for($i = 0; $i < 6; $i++)
{
        if($my_array[$i] == $test_char)
                echo("php's 'if' tells us that {$my_array[$i]} is the same
as {$test_char}\n");
        else
                echo("php's 'if' tells us that {$my_array[$i]} is not the
same as {$test_char}\n");
}

Expected result:
----------------
php's 'if' tells us that 0 is not the same as a
php's 'if' tells us that 1 is not the same as a
php's 'if' tells us that 0 is not the same as a
php's 'if' tells us that 1 is not the same as a
php's 'if' tells us that a is the same as a
php's 'if' tells us that b is not the same as a


Actual result:
--------------
php's 'if' tells us that 0 is the same as a
php's 'if' tells us that 1 is not the same as a
php's 'if' tells us that 0 is not the same as a
php's 'if' tells us that 1 is not the same as a
php's 'if' tells us that a is the same as a
php's 'if' tells us that b is not the same as a


-- 
Edit bug report at http://bugs.php.net/?id=28986&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28986&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28986&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28986&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28986&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28986&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28986&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28986&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28986&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28986&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28986&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28986&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28986&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28986&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28986&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28986&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28986&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28986&r=float

Reply via email to