|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-07-22 22:46 UTC] nielsene at mit dot 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;
?>
--
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Fri Jun 19 11:00:01 2026 UTC |
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