I have an Elseif statement, which gets a template name and includes the template PHP file which contains a large array, it outputs the result on the page.
$template = str_replace("-","_","{$_GET['select']}");
if ($template == "cuatro"){
include("templates/cuatro.php");
echo $page_output;
} elseif ($template == "ohlittl"){
include("templates/ohlittl.php");
echo $page_output;
} else {
echo "Sorry, template not found.";
}
$page_output = "You've chosen $template_select[0].";
From there, I get a notice saying it couldn’t find the $page_output variable.
Notice: Undefined variable: page_output in C:\ … \template.php on line 10
It can find it if I put the variable in the included file though. But I’m trying to get this variable to remain on this page. How do I complete this?
You are defining
$page_outputafter you are echoing it. At the time you call echo$page_outputit doesn’t exist yet.Try:
Although I have no idea how you are setting
$template_selectand if you are aware it will always say the same template name?An alternative approach that I believe achieves what you want: