Re: how to get the absolute path of an included file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Brad Bonkoski schrieb:


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

nonsense. Only for functions and such.

If it's in the same folder why dont you use include ("file2.php"); ?

Otherwise youse pathes like ../subfolder/folder
Only if you really want to load stuff thats not at the web directory use full pathes like /path/to/folder

Barry

--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux