TheEddy Posted August 3, 2010 Share Posted August 3, 2010 <?php $pageTitle='Edit Profile'; require_once ("header.php"); ?> How can I pass a variable like that through header.php? I know it doesn't work the way I have it. Link to comment https://forums.phpfreaks.com/topic/209706-passing-a-variable-with-a-require-once-code/ Share on other sites More sharing options...
AbraCadaver Posted August 3, 2010 Share Posted August 3, 2010 <?php $pageTitle='Edit Profile'; require_once ("header.php"); ?> How can I pass a variable like that through header.php? I know it doesn't work the way I have it. What doesn't work? If you echo $pageTitle in header.php it will work, unless header.php has already been included/required. Link to comment https://forums.phpfreaks.com/topic/209706-passing-a-variable-with-a-require-once-code/#findComment-1094754 Share on other sites More sharing options...
TheEddy Posted August 3, 2010 Author Share Posted August 3, 2010 <?php $pageTitle='Edit Profile'; require_once ("header.php"); ?> How can I pass a variable like that through header.php? I know it doesn't work the way I have it. What doesn't work? If you echo $pageTitle in header.php it will work, unless header.php has already been included/required. I am an idiot, I see the problem now haha. I had: <title>$pageTitle</title> in header.php and it displayed $pageTitle as the title. Link to comment https://forums.phpfreaks.com/topic/209706-passing-a-variable-with-a-require-once-code/#findComment-1094758 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.