|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-09-05 15:36 UTC] roland dot dufour at multiprog dot net
[2008-09-05 17:11 UTC] tularis@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 01:00:01 2025 UTC |
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)