ID: 30285 Comment by: Jared dot Williams1 at ntlworld dot com Reported By: benjcarson at digitaljunkies dot ca Status: Open Bug Type: Zend Engine 2 problem Operating System: Debian Linux PHP Version: 5CVS-2004-09-30 (dev) New Comment:
5.0.2 does produce the expected result, as does 4.3.8 Previous Comments: ------------------------------------------------------------------------ [2004-09-30 05:25:18] benjcarson at digitaljunkies dot ca Description: ------------ It seems that the default: block of a switch statement now short-circuits the remaining case: tests. If the default: block is put before a matching case: block, it will _always_ be executed. While the docs (http://www.php.net/manual/en/control-structures.switch.php) do recommend making default: last, this is a BC break (tested with 5.0.0 and 4.3.2). This bug is also present at least as early as the 5.1.x-dev 2004-09-25 snap (sorry, the next earliest one I have is 5.0.0). The reproduce code below works if the default: block is put after the case "a": block. Reproduce code: --------------- <?php $x = "a"; switch ($x) { default: echo "default\n"; break; case "a": echo "case: a\n"; break; } ?> Expected result: ---------------- case: a Actual result: -------------- default ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=30285&edit=1
