Bug #68105 [NEW]: Switch shouldn't show notices for undefined variables

From: Date: Fri, 26 Sep 2014 08:25:46 +0000
Subject: Bug #68105 [NEW]: Switch shouldn't show notices for undefined variables
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187713@lists.php.net to get a copy of this message
From: jacob87 at o2 dot pl Operating system: PHP version: 5.5.17 Package: Output Control Bug Type: Bug Bug description:Switch shouldn't show notices for undefined variables Description: ------------ Switch should not show notices about undefined variables, as it can have it's default action. So, the notice shouldn't show up if switch has default action (best implementation). Or not show notices at all (easier). You could say "just turn off notices in production environment". That is not the case. In development environment some scripts can fail because of "Headers already sent". And I don't want to write redundant code such as if(!isset($var))$var=''; Test script: --------------- switch($action){ default: echo 'This shouldn't show a notice!'; break; } Expected result: ---------------- This shouldn't show a notice! Actual result: -------------- Notice: Undefined variable: action in (...) This shouldn't show a notice! -- Edit bug report at https://bugs.php.net/bug.php?id=68105&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68105&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68105&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68105&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=68105&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=68105&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=68105&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=68105&r=needscript Try newer version: https://bugs.php.net/fix.php?id=68105&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=68105&r=support Expected behavior: https://bugs.php.net/fix.php?id=68105&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=68105&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=68105&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=68105&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68105&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=68105&r=dst IIS Stability: https://bugs.php.net/fix.php?id=68105&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=68105&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=68105&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=68105&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=68105&r=mysqlcfg

« previous php.bugs (#187713) next »