php question include statement with variable
-
Trying to figure out a simple fix and my PHP is not up to par… I’m trying to create a dynamic include statement so that the page you are on generates the appropriate side bar. Example:
<?php
$page = the_title();
$sidebar = “Sidebar.php”;
$combine = $page . $sidebar;
include($combine);
?>So if you’re on the index page
the_title() = indexI want ‘index’ to combine with ‘Sidebar.php’ to form:
indexSidebar.phpthe include statement would look like this in a page source view:
include(‘indexSidebar.php’);
***when I replace the include statement with:
echo $combine
the result is: indexSidebar.php
its breaking when I try to pass the $combine variable in the include statement…
The topic ‘php question include statement with variable’ is closed to new replies.