View Full Version : get variable from included file

01-09-2010, 06:50 PM

I have a master file in which I have included two external files. I tried to echo a variable in the 1st included file, which is defined in the second included file but it didn't work?

// File that tries to get the variable
<?php include("1st_file.php"); ?>

// File that defines the variable
<?php include("2nd_file.php"); ?>

How can I get a variable that is created in 2nd_file.php to 1st_file.php ?:confused:

01-09-2010, 06:52 PM
You cannot access a variable that does not yet exist.