Bug #70706 [NEW]: Doesn't evaluate 0
| From: | raquilesc at gmail dot com | Date: | Tue, 13 Oct 2015 04:16:41 +0000 |
| Subject: | Bug #70706 [NEW]: Doesn't evaluate 0 | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-196587@lists.php.net to get a copy of this message | ||
From: raquilesc at gmail dot com
Operating system: Linux
PHP version: 5.5.30
Package: *General Issues
Bug Type: Bug
Bug description:Doesn't evaluate 0
Description:
------------
This code fails, 0 gets ignored and is catch by the 2nd case instead of
the first one. Basically indicating than 0 is greater that 69. To
evaluate a lower value you need to set it up to 1.
$a = 0;
switch ($a){
case ($a <= 69) : echo "Less than or equal 69"; break;
case ($a > 69 && $a < 80) : echo "greater than 69" ; break;
case ($a >= 80) : echo "greater or equal 80" ; break;
}
Test script:
---------------
This code fails, 0 gets ignored and is catch by the 2nd case instead of
the first one. Basically indicating than 0 is greater that 69. To
evaluate a lower value you need to set it up to 1.
$a = 0;
switch ($a){
case ($a <= 69) : echo "Less than or equal 69"; break;
case ($a > 69 && $a < 80) : echo "greater than 69" ; break;
case ($a >= 80) : echo "greater or equal 80" ; break;
}
Expected result:
----------------
It should evaluate 0 as a value and it is not.
--
Edit bug report at https://bugs.php.net/bug.php?id=70706&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70706&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70706&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70706&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70706&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70706&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70706&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70706&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70706&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70706&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70706&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70706&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70706&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70706&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70706&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70706&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70706&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70706&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70706&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70706&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70706&r=mysqlcfg