Error with global variable in php not extending to included php file
- by phileaton
I have an html file that calls has a php section in the header like so:
$page = basename($_SERVER['PHP_SELF']);
Now further down in the html file I have a included footer like so:
<?php include("footer.php"); ?>
In this script I am referencing the $page variable, but it doesn't find it. I tried echoing the variable and nothing happened. When I place the basename() code in the footer.php file though, it handled it fine. I'd like to be efficient with the coding, so how can I get the footer.php file to get that $page variable? Is there a better way to do this than including the $page variable twice?