r22pl Posted March 7, 2006 Share Posted March 7, 2006 The way I have my index.php file start is:[code]<?php$pagename = "Home";require_once("include/common.inc.php");page_header();?>[/code]common.inc.php includes all of my includes and classes, such as [b]page.inc.php[/b]:[code]<?phpsession_start();// Start Headerfunction page_header() {?> <?php echo "$pagename"; ?>[/code]I can't get it to recognize the variable [b]$pagename[/b], which I need for the title, nav, etc. Link to comment https://forums.phpfreaks.com/topic/4373-outside-variable-to-work-with-include-function/ Share on other sites More sharing options...
Steveo31 Posted March 7, 2006 Share Posted March 7, 2006 Yea there's a little trick to that:[code]<?phpsession_start();// Start Headerfunction page_header(&$pagename) { echo "$pagename";}[/code]The & sign means its passing by reference or something like that. Check the manual. Link to comment https://forums.phpfreaks.com/topic/4373-outside-variable-to-work-with-include-function/#findComment-15187 Share on other sites More sharing options...
r22pl Posted March 7, 2006 Author Share Posted March 7, 2006 Thanks, that worked! Link to comment https://forums.phpfreaks.com/topic/4373-outside-variable-to-work-with-include-function/#findComment-15189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.