Page 1 of 1

Outside variable to work with include function

Posted: Tue Mar 07, 2006 3:53 pm
by r22pl
The way I have my index.php file start is:

Code: Select all

<?php
$pagename = "Home";
require_once("include/common.inc.php");
page_header();
?>
common.inc.php includes all of my includes and classes, such as page.inc.php:

Code: Select all

<?php
session_start();

// Start Header
function page_header() {
?>
	
	<?php
	echo "$pagename";
	?>
I can't get it to recognize the variable $pagename, which I need for the title, nav, etc.

Posted: Tue Mar 07, 2006 4:11 pm
by feyd
lookup the "global" keyword, however I'd recommend passing $pagename to the function.

Posted: Tue Mar 07, 2006 4:14 pm
by r22pl
Thanks, I passed $pagename to the function and it worked