Bug #68105 [Opn->Wfx]: Switch shouldn't show notices for undefined variables
| From: | requinix@php.net | Date: | Fri, 26 Sep 2014 09:17:07 +0000 |
| Subject: | Bug #68105 [Opn->Wfx]: Switch shouldn't show notices for undefined variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187715@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68105&edit=1
ID: 68105
Updated by: requinix@php.net
Reported by: jacob87 at o2 dot pl
Summary: Switch shouldn't show notices for undefined
variables
-Status: Open
+Status: Wont fix
Type: Bug
Package: Output Control
PHP Version: 5.5.17
Block user comment: N
Private report: N
New Comment:
Doing so would cause much harm for very little good. The variable is undefined so don't try to
use it, period. It's a simple rule that's very easy to follow.
Previous Comments:
------------------------------------------------------------------------
[2014-09-26 08:25:45] jacob87 at o2 dot pl
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 this bug report at https://bugs.php.net/bug.php?id=68105&edit=1