note 28939 added to control-structures.switch

From: Date: Tue, 28 Jan 2003 17:53:51 +0000
Subject: note 28939 added to control-structures.switch
Groups: php.notes 
Request: Send a blank email to php-notes+get-42941@lists.php.net to get a copy of this message
Hi, I used this code to parse through a template html file .. I just want to get displayed an other template, if the switch changes. With this script i just get viewed the first case. No matter what $cmd here is, i always get the template output for "news".. even if i delete or comment the "default" part. Can anybody tell me whats going wrong here? ------ $template = "templates/index.html"; $output = implode(" ", file($template)); switch ($cmd) { case news: $ext_template = "templates/news.html"; $ext_output = implode(" ", file($ext_template)); $output = str_replace('{Module_Body}', $ext_output, $output); break; case member: $ext_template = "templates/member.html"; $ext_output = implode(" ", file($ext_template)); $output = str_replace('{Module_Body}', $ext_output, $output); break; default: $ext_template = "templates/news.html"; $ext_output = implode(" ", file($ext_template)); $output = str_replace('{Module_Body}', $ext_output, $output); break; } echo $output; -- http://www.php.net/manual/en/control-structures.switch.php http://master.php.net/manage/user-notes.php?action=edit+28939 http://master.php.net/manage/user-notes.php?action=delete+28939 http://master.php.net/manage/user-notes.php?action=reject+28939

« previous php.notes (#42941) next »