Jump to content


Photo

variables and values


  • Please log in to reply
4 replies to this topic

#1 pneudralics

pneudralics
  • Members
  • PipPipPip
  • Advanced Member
  • 241 posts

Posted 02 March 2006 - 10:18 PM

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?

#2 markduce

markduce
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 02 March 2006 - 10:22 PM

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:

<?php
include ("mastervariables.php");
?>

Hope that helps

Mark

#3 pneudralics

pneudralics
  • Members
  • PipPipPip
  • Advanced Member
  • 241 posts

Posted 02 March 2006 - 10:47 PM

[!--quoteo(post=351134:date=Mar 2 2006, 06:22 PM:name=markduce)--][div class=\'quotetop\']QUOTE(markduce @ Mar 2 2006, 06:22 PM) View Post[/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:

<?php
include ("mastervariables.php");
?>

Hope that helps

Mark
[/quote]

So once I add:
<?php
include ("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:
<?php
include ("/newdirectory/mastervariables.php");
?>

Correct?

Thanks in advance.


#4 grim1208

grim1208
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts

Posted 02 March 2006 - 11:05 PM

[!--quoteo(post=351145:date=Mar 2 2006, 06:47 PM:name=pneudralics)--][div class=\'quotetop\']QUOTE(pneudralics @ Mar 2 2006, 06:47 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
So once I add:
<?php
include ("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:
<?php
include ("/newdirectory/mastervariables.php");
?>

Correct?

Thanks in advance.
[/quote]
That would work :)

grim1208
New Web Projects

#5 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 03 March 2006 - 03:37 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users