elefant Posted November 28, 2007 Share Posted November 28, 2007 Hi. Let's say, hypothetically... You make a header script. In this header you make the page title for the hypertext a variable. <title><?=$page_title?></title> I've also tried, echo with " and ' and also ended the declaration properly with ; in many of the ways I've attempted to get this to work Now, in a seperate file, let's say it is just some random page on your website, you... <? $page_title = "This is my page"; include_once('header.php'); ?> This application works wonderfully... If, that is, the header and random webpage are located in the same directory... But, at least to me, this nearly defeats the whole purpose. Sure, it is easier to edit one header, possibly linking to 50 files per directory, but isn't it easier to edit one header in total? My question is, and I know this can be done as massive software like phpBB/SMF use only one header, how in the world can I get a variable to pass from one file to another when one of the files is in a completely different directory stack?? (And yes, I am aware that you can ('http://website/dir1/dir2/file.php') call a file in that manner but even this fails to translate variables located in a different stack, at least how I'm doing them now). Quote Link to comment https://forums.phpfreaks.com/topic/79223-two-files-one-variable/ Share on other sites More sharing options...
adam291086 Posted November 28, 2007 Share Posted November 28, 2007 ok i think i know what you want. In your include part you just set up the directory. ../ = route So if you make a file call php, which stores all you php file you will include in like include_once('../phpfolder/header.php') I think that is correct if not remove the ../ and just and phpfolder Quote Link to comment https://forums.phpfreaks.com/topic/79223-two-files-one-variable/#findComment-400986 Share on other sites More sharing options...
elefant Posted November 28, 2007 Author Share Posted November 28, 2007 Thanks but that does not help. I've tried that. The situation is this - Scenario a) root/dir1/dir2/file where variable is defined In the same dir the file using the variable is used When this is the arrangement the variable is passed. Scenario b) root/dir1/dir2/file where the variable is defined root/dir3/dir4/file where the variable is used With this arrangement the variable fails to translate. It does not matter what I do when calling header, if it's not in the same directory stack it simply doesn't translate. It could be any of the following ./dir3/dir4/file = fail ../../file = fail http://propersubdomain.site.com/scripts/file = the page loads but no variable translation in sight http://site.com/subdomainasfolder/scripts/file = see above Quote Link to comment https://forums.phpfreaks.com/topic/79223-two-files-one-variable/#findComment-401000 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.