Jump to content

Recommended Posts

I have a page in which i require another page. For instance I want a variable (the page title) in 'main.php' to pass to the required page (template).  The reqired page contains my header, nav, footer, etc. 

 

So, in main.php i have:

 

<?php

require_once("template.php");

?>

 

<?php

$page_title = 'Home';

?>

 

In the header section of template.php, I want to use the variable $page_title to print as Home.

Something like <title>print $page_title</title>

 

This can't be that difficult, but check out my ID...newnewbie!

 

Thankx in advance as always!

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/198000-pass-a-variable-to-a-required-page/
Share on other sites

All that time and all I had to do was put the variables before the require code.  This worked and actually solved two of my problems  I have been teaching myself php for a couple of weeks...sooo much to learn.  Thank you for helping my day be much brighter!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.