Re: Detect php filepath
| From: | Camilo Sperberg | Date: | Wed, 28 Sep 2016 11:16:57 +0000 |
| Subject: | Re: Detect php filepath | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-325750@lists.php.net to get a copy of this message | ||
__FILE__ (double underscore at beginning and end) is a constant which will
contain the path of the file where it is called. You can use that to
implement the functions.
What do you want to accomplish if I may ask?
Greetings.
On Wed, Sep 28, 2016 at 1:16 PM, Camilo Sperberg <me@unreal4u.com> wrote:
> __FILE__ (double underscore at beginning and end) is a constant which will
> contain the path of the file where it is called. You can use that to
> implement the functions.
>
> What do you want to accomplish if I may ask?
>
> Greetings.
>
> On Wed, Sep 28, 2016 at 12:56 PM, Narcis Garcia <informatica@actiu.net>
> wrote:
>
>> Hello, I'm writing in PHP 5.
>>
>> How can I get the local and/or public path of the script file with
>> current function? And a caller one?
>>
>> Example:
>> /srv/www/index.php includes material/index.php
>> /srv/www/material/index.php includes ../functions.php
>>
>> in /srv/www/functions.php :
>> function LocalFileIAm()
>> {
>> return ...;
>> }
>> function RemoteFileIAm()
>> {
>> return ...;
>> }
>>
>> in /srv/www/material/index.php :
>> echo '<p>Materials local index file is at:
>> '.LocalFileIAm().'</p>';
>> echo '<p>Materials public index file is at:
>> '.RemoteFileIAm().'</p>';
>>
>> Wnen visiting http://www.mysite.net/index.php browser
>> should show:
>> Materials local index file is at: /srv/www/material/index.php
>> Materials public index file is at: /material/index.php
>>
>> Thanks.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
--
Mailed by:
UnReAl4U - unreal4u
ICQ #: 54472056
www1: http://www.chw.net/
www2: http://unreal4u.com/