Re: Detect php filepath

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

 



Thanks;
The purpose is to develop a "plugin" for different applications, and
then locate more files for inclusion.

/srv/www/application1/index.php ->
/srv/www/application1/modules/myplugin/index.php ->
/srv/www/application1/modules/myplugin/functions.php

/srv/www/application2/index.php ->
/srv/www/application2/extensions/myplugin/index.php ->
/srv/www/application2/extensions/myplugin/functions.php

I need to "myextension" works independently of the path it's located and
base URL is visited.
Example for myplugin/index.php :
$LocalAppDir = dirname(__FILE__);

include $LocalAppDir.'/functions.php';



El 28/09/16 a les 13:16, Camilo Sperberg ha escrit:
> __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@xxxxxxxxx>
> 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
>>
>>
> 

-- 
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