Bug #18483 Updated: include fails in a switch context
| From: | derick@php.net | Date: | Tue, 23 Jul 2002 12:50:56 +0000 |
| Subject: | Bug #18483 Updated: include fails in a switch context | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-14874@lists.php.net to get a copy of this message | ||
ID: 18483
Updated by: derick@php.net
Reported By: nielsene@mit.edu
Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.1.2
New Comment:
it has nothing to do with the include statement, but with the switch()
statement. Switch() just expects "case " or "default" there. I'm fairly
sure this works:
switch ($foo) {
case 1: include "bar.inc"; break;
}
It's just not supported.
Derick
Previous Comments:
------------------------------------------------------------------------
[2002-07-23 08:47:10] nielsene@mit.edu
I'm sorry, I don't see how this is not a bug. I checked over the
documentation included user comments before submitting this. No where
does it mention that includes are not valid within a switch context.
It does mention the need for the braces within a conditional context,
which led me to beleive it should work within a switch. If the parser
is behaving correctly, then this might be a documentation oversight.
------------------------------------------------------------------------
[2002-07-23 01:37:06] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
------------------------------------------------------------------------
[2002-07-22 22:46:07] nielsene@mit.edu
Using an include (or require) from within a switch statement, generates
a parse error (expecting T_CASE or T_DEFAULT).
--test.php
<?php
$foo=1;
switch($foo)
{
include "bar.inc";
}
exit;
?>
--bar.inc
<?php
case 1: echo "1"; break;
case 2: echo "2"; break;
default : echo "3"; break;
?>
--
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=18483&edit=1