Bug #18483 Updated: include fails in a switch context

From: Date: Tue, 23 Jul 2002 13:15:23 +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-14877@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: Feature/Change Request Operating System: Linux PHP Version: 4.1.2 New Comment: Since you ask, I'm trying to keep the include files as simple and short as possible. First, I find it helps readability to make the main boiler-plate code as completed as possible. Second,I'm trying to keep the automated code generation code simple. In many cases I'm outputing code that when run will then output html. At all points along the way I want the first, and second generation outputs to be well formated. As a result the code generation is already a nightmare of singly and doubly escaped control characters so that they (tabs/newlines) get passed through to the different levels. I am going to move the switch to the include files as its the only workaround availible at present. I had fallen back into the trap of thinking of include() like a preprocessor-like command. Previous Comments: ------------------------------------------------------------------------ [2002-07-23 08:59:38] derick@php.net Why don't you include the switch() itself in the include file? Derick ------------------------------------------------------------------------ [2002-07-23 08:54:44] nielsene@mit.edu 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. ------------------------------------------------------------------------ [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 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/18483 -- Edit this bug report at http://bugs.php.net/?id=18483&edit=1

« previous php.bugs (#14877) next »