Re: absolute path of any PHP script?
| From: | Cynic | Date: | Sat, 06 Jan 2001 04:53:17 +0000 |
| Subject: | Re: absolute path of any PHP script? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33021@lists.php.net to get a copy of this message | ||
Richard, I wish it was that easy.
test.php:
<? include( './include.inc' ) ; ?>
iclude.inc:
<? echo $HTTP_SERVER_VARS['PHP_SELF'] ?>
output:
/path/to/test.php
^^^^^^^^
echo __FILE__ would output './include.inc', while I need
'/path/to/include.inc'... I _have_ spent some cycles on this,
and, while it might sound funny, am glad I'm not the only one
who doesn't know it. :)
At 04:54 6.1. 2001, Richard Lynch wrote the following:
--------------------------------------------------------------
>$PHP_SELF, I think...
>
>Put <?php phpinfo();?> in foo and then in bar and see what's available.
>
>
>
>----- Original Message -----
>From: Cynic <cynic@mail.cz>
>Newsgroups: php.general
>Sent: Friday, January 05, 2001 8:18 AM
>Subject: [PHP] absolute path of any PHP script?
>
>
>> how do I get the absolute path to any PHP script currently
>> being executed?
>> __FILE__ does not help here, because if I have
>> require( '../bar.php' ) ;
>> in foo.php, __FILE__ in foo.php will contain e. g.
>> 'c:/wwwroot/aaa/bbb/foo.php' (on windows), but in bar.php it
>> will contain '../bar.php' (e. g. the argument passed to
>> require()).
>> I know I could write a function to do this, but surely
>> there must be an easier way I just missed.
>>
>> TIA
>>
>> ____________________________________________________________
>> Cynic:
>>
>> A member of a group of ancient Greek philosophers who taught
>> that virtue constitutes happiness and that self control is
>> the essential part of virtue.
>>
>> cynic@mail.cz
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>> For additional commands, e-mail: php-general-help@lists.php.net
>> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz