Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Including a conf file

Status
Not open for further replies.

vcherubini

Programmer
May 29, 2000
527
US
Hello:

I am pretty new to the world of PHP, so please bear with me.

Say I have a file, .php or .php3, and it has a lot of variables in it that are global and can be used on every page that it is included in.

So say the file is named include.php3 and has information such as this within it:

[tt]
$name = "your name";
$age = "your age";
$height = "your height";

[/tt]

Ok, if I included that file with another PHP file, and use the variable $name, will it have the value "your name" or will it have no value?

I know that if you have a main functions file and include that, you can call functions from that file, so I would assume variables would be the same way.

Any help is appreciated.

Thanks.

-Vic

vic cherubini
malice365@hotmail.com
====

Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

Wants to Know: Java, Cold Fusion, Tcl/TK

====
 
Variable $name will indeed be initialized with the value "your name" if you include the php file -- provided that you aren't trying to access the variable from a custom function. In that case you do need to declare $name as global (simply "global $name;") within the said function.

Hope this helps.

brendanc@icehouse.net
 
Thanks a bunch for that. I had been thinking that the entire time. Man that is much easier than perl.

Thanks for the help again. I will keep posting when I need it. =)

-Vic

vic cherubini
malice365@hotmail.com
====

Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

Wants to Know: Java, Cold Fusion, Tcl/TK

====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top