Re: how to get the absolute path of an included file?
| From: | Bing Du | Date: | Fri, 28 Apr 2006 17:21:54 +0000 |
| Subject: | Re: how to get the absolute path of an included file? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-235026@lists.php.net to get a copy of this message | ||
Thanks all who replied. So the include path used in file2.php should be
relative to the working directory where file2.php is located. Yes, I have
error_reporting=E_ALL in my php.ini. The log shows include_path=.|xxxx.
But in my situation, it took me a while to figure out what that '.' really
means because file2.php is not an actual file on the filesystem.
file2.php is a PHP content element in a web application. Anyway, I've
figured out.
Bing
> 2006/4/27, Bing Du <bdu@iastate.edu>:
>>
>> 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';
>> echo "var is $var";
>> ?>
>> =>
>> Thanks,
>>
>> Bing
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> Activate reporting of all errors either through php.ini or
> error_reporting(E_ALL);
> Use include_once instead of include. That way the program will stop if it
> couldn't include the file.
> Try using a relative path to the file.
>