Jump to content

[SOLVED] Passing a variable upward???


jwwceo

Recommended Posts

I have a question which Im sure has an easy answer..at least I am thinking it does..

 

IS it possible to pass a variable upward??

 

For example, if I have a page with a header template, a content section, and then a footer; how would I use a variable that's in a content page, in the header. My specific problem is that I want to use custom title pages for my site. But the header is always the same. So I was thinking I can just put a title variable ( $title ) in my content section for each page. But how would I pass this info into the header.

 

I realize I could also write if statements in the header, but how wold the header know which page is being used in the content?? Is there a function to grab the current URL? and then what if that URL is full of Get values??

 

Any tips would be awesome!!

 

James

Link to comment
https://forums.phpfreaks.com/topic/82755-solved-passing-a-variable-upward/
Share on other sites

What you do is on the content page you create all of the variables you want the header to use.  Then include the header.  There's nothing saying you have to include the header before writing the rest of your code on the page.  Write your page-level variables first, then include the header, and that will allow you to use the page-level variables in the header.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.