pneudralics Posted March 2, 2006 Share Posted March 2, 2006 I'm new to php and still trying to learn it. If I had me.php do I have to assign the variables and values to me.php? Can I create some kind of master list of variables and values so I can use those in me.php? Quote Link to comment Share on other sites More sharing options...
markduce Posted March 2, 2006 Share Posted March 2, 2006 Hi,Yes, you can create a list of master variables.Say you set up a file called mastervariables.php and put it in the same folder as me.php.Then list your variables in there eg<?php$variable1="hello";$variable2="hello2";?>Then on me.php, simply include the file with the following code:<?phpinclude ("mastervariables.php"); ?>Hope that helpsMark Quote Link to comment Share on other sites More sharing options...
pneudralics Posted March 2, 2006 Author Share Posted March 2, 2006 [!--quoteo(post=351134:date=Mar 2 2006, 06:22 PM:name=markduce)--][div class=\'quotetop\']QUOTE(markduce @ Mar 2 2006, 06:22 PM) [snapback]351134[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi,Yes, you can create a list of master variables.Say you set up a file called mastervariables.php and put it in the same folder as me.php.Then list your variables in there eg<?php$variable1="hello";$variable2="hello2";?>Then on me.php, simply include the file with the following code:<?phpinclude ("mastervariables.php"); ?>Hope that helpsMark[/quote]So once I add:<?phpinclude ("mastervariables.php"); ?>me.php will use those variables?If I want to add variables in a different directory I'll just have to do this:<?phpinclude ("/newdirectory/mastervariables.php"); ?>Correct?Thanks in advance. Quote Link to comment Share on other sites More sharing options...
grim1208 Posted March 2, 2006 Share Posted March 2, 2006 [!--quoteo(post=351145:date=Mar 2 2006, 06:47 PM:name=pneudralics)--][div class=\'quotetop\']QUOTE(pneudralics @ Mar 2 2006, 06:47 PM) [snapback]351145[/snapback][/div][div class=\'quotemain\'][!--quotec--]So once I add:<?phpinclude ("mastervariables.php"); ?>me.php will use those variables?If I want to add variables in a different directory I'll just have to do this:<?phpinclude ("/newdirectory/mastervariables.php"); ?>Correct?Thanks in advance.[/quote]That would work :) Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 3, 2006 Share Posted March 3, 2006 FYI include and require act a bit like copy 'n' paste. So when you include mastervariables.php then what ever is in that file, is effectively being copy 'n' peste'd in to me.php Quote Link to comment 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.