ID:               46004
 Updated by:       [EMAIL PROTECTED]
 Reported By:      roland dot dufour at multiprog dot net
-Status:           Open
+Status:           Bogus
 Bug Type:         *General Issues
 Operating System: Windows Vista Ultimate French
 PHP Version:      5.2.6
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Please read the documentation:
http://www.php.net/manual/en/types.comparisons.php

It clearly states:
(int) 0 == (string) "php"
(or any string for that matter), this is due to PHP's loose typing
auto-converting both to integers (and "php" changes to (int) 0; 0 == 0,
so true)


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

[2008-09-05 15:36:48] roland dot dufour at multiprog dot net

With a non strict condition, the expected result is :
bool(true) bool(false) bool(true)

And, with a strict condition, the expected result is :
bool(false) bool(false) bool(true)

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

[2008-09-05 15:33:49] roland dot dufour at multiprog dot net

Description:
------------
When I try a non strict condition 0 == 'test', PHP return true.

Reproduce code:
---------------
// Non-strict condition 
var_dump((0 == 'test'));
var_dump((1 == 'test'));
var_dump(('test' == 'test'));

// Strict condition 
var_dump((0 === 'test'));
var_dump((1 === 'test'));
var_dump(('test' === 'test'));

Expected result:
----------------
bool(false) bool(false) bool(true) 

I don't understand why a condition 0 == 'test' return true.
I discovered this "bug" by exploring the keys of a table via the
instruction "foreach". My code was then:

$options = array(
        array(), // an array
        array(), // an other array
        'refProduct' => 'test' // a value
);
foreach ($options as $k => $option) {
        if ('refProduct' == $k){
                continue;
        }
        // Instructions...
}

Curiously, only my secondary table ("an other array") was executed by
"Instructions...".

Actual result:
--------------
bool(true) bool(false) bool(true) 


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


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

Reply via email to