ID:               46004
 User updated by:  roland dot dufour at multiprog dot net
 Reported By:      roland dot dufour at multiprog dot net
 Status:           Open
 Bug Type:         *General Issues
 Operating System: Windows Vista Ultimate French
 PHP Version:      5.2.6
 New Comment:

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)


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

[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