garek007 Posted June 30, 2009 Share Posted June 30, 2009 Hi, I'll try to explain this as best I can. I have a document that gets included into another document. This document is a navigation pane and simply holds links to other documents. I'm wondering if I can define a variable in the page that my navigation document is linking to and use that variable to set the text using an echo statement in the navigation document. See it seems weird, seems like a loop. I want the document that it links to, to define the link itself. Can that be done? Thanks, Stan Link to comment https://forums.phpfreaks.com/topic/164282-use-a-variable-in-one-page-to-determin-links-in-another/ Share on other sites More sharing options...
rhodesa Posted June 30, 2009 Share Posted June 30, 2009 so...let me see if i can get this straight...you have index.php, which includes nav.php. nav.php has a bunch of links, one of which points to page.php. In page.php you have a variable called $title and it is set to "This is a page". you are wondering if it is possible to access that variable via loading index.php with nav.php included? no, you cannot. i assume you are trying to do something along the lines of getting the title of the page dynamically so you don't have to update it in two places. the only way to accomplish this is to have a central file that defines it that both nav.php and page.php include. for instance, you can have a file called config.php and in it: <?php $page_titles['page.php'] = "This is a page"; ?> then, you can include this file wherever you want and have access to that data. does that help? Link to comment https://forums.phpfreaks.com/topic/164282-use-a-variable-in-one-page-to-determin-links-in-another/#findComment-866614 Share on other sites More sharing options...
garek007 Posted June 30, 2009 Author Share Posted June 30, 2009 Thanks I didn't think so. I had another idea as I was doing this, I'll post it now. It's relating to SEO Link to comment https://forums.phpfreaks.com/topic/164282-use-a-variable-in-one-page-to-determin-links-in-another/#findComment-866697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.