|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-11-05 10:17 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2014-11-05 10:17 UTC] requinix@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 02:00:01 2025 UTC |
Description: ------------ When a variable is stored via $_GET method (even when parsing to integer) and used in a switch, fails on case 0. When you use it like: example.php?num=0 You will get the result: "The number 0 is higer than 5." (Obiously fail) But if you use 00 instead of 0: example.php?num=00 You will get the result: "The number 00 is lower than 2." (Which is true) It also works with " 0": example.php?num= 0 You will get the result: "The number 00 is lower than 2." (Which is true) Test script: --------------- $number = $_GET['num']; // $number = intval($_GET['num']); // $number = (int) $_GET['num']; switch ($number) { case ($number<2): $result = 'lower than 2'; break; case ($number<5): $result = 'lower than 5'; break; case ($number>=5): $result = 'higer than 5'; break; // Se mete aqui con nota = 10 } echo "The number " . $number . " is " . $result . "."; Expected result: ---------------- The number 0 is lower than 2. Actual result: -------------- The number 0 is higer than 5.