Bing Du wrote:

Hello,

Here are the two scripts.  The result is 'var is' rather than 'var is
foo'.  My suspect is I did not set the file path right in 'include'.  So
in file2.php, how should I get the actual absolute path it really gets for
file1.php?  Is it stored in some environment variable or something?  I'd
appreciate any help.

file1.php

==
<?php
$var = 'foo';
?>
==

file2.php

==
<?php

include '/some/path/file1.php';
global $var; //you have to declare it as a global otherwise it will assume a local value

echo "var is $var";
?>
==

Thanks,

Bing


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to