Bug #60000 [Com]: switch with int(0)

From: Date: Tue, 28 Jun 2011 22:23:01 +0000
Subject: Bug #60000 [Com]: switch with int(0)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-161398@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=60000&edit=1 ID: 60000 Comment by: giorgio dot liscio at email dot it Reported by: k at twojepc dot pl Summary: switch with int(0) Status: Open Type: Bug Package: *Programming Data Structures Operating System: Debian/Windows PHP Version: 5.3.6 Block user comment: N Private report: N New Comment: 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; } Previous Comments: ------------------------------------------------------------------------ [2011-06-28 17:35:13] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60000&edit=1

« previous php.bugs (#161398) next »