|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-06-28 17:35 UTC] k at twojepc dot pl
Description:
------------
Switch use first case element when we use integer zero value.
Test script:
---------------
<?php
$var=0;
switch ($var)
{
case "abc":
echo "abc";
break;
case "zxc":
echo "zxc";
break;
default:
echo "def";
break;
}
Expected result:
----------------
def
Actual result:
--------------
abc
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 08:00:01 2025 UTC |
switch uses the == operator so bogus $var = 0; switch (true) { case $var === "abc": echo "abc"; break; case $var === "zxc": echo "zxc"; break; default: echo "def"; break; }