Bug #18483 Updated: include fails in a switch context
| From: | nielsene at mit dot edu | Date: | Tue, 23 Jul 2002 12:54:45 +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-14875@lists.php.net to get a copy of this message | ||
ID: 18483
Updated by: nielsene@mit.edu
Reported By: nielsene@mit.edu
Status: Bogus
-Bug Type: Scripting Engine problem
+Bug Type: Feature/Change Request
Operating System: Linux
PHP Version: 4.1.2
New Comment:
I'll change this from a bug report to a feature request as it appears
that this is an unsupported use combination of switch/include.
I'm writing a family of closely related websites. Costumization code
is written by a configurer for including at various points in the
boiler-plate code. In several locations this customization code is the
body of the switch, with the default being constant between sites, so
the include file is just a list of case statements.
Previous Comments:
------------------------------------------------------------------------
[2002-07-23 08:50:55] derick@php.net
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
------------------------------------------------------------------------
[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