Re: [PHP] Detect php filepath
- Date: Wed, 28 Sep 2016 14:29:31 +0100
- From: Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx>
- Subject: Re: [PHP] Detect php filepath
On 28 September 2016 14:25:55 BST, Narcis Garcia <informatica@xxxxxxxxx> wrote:
>The purpose is to develop a "plugin" for different applications, and
>then locate more files for inclusion.
>I need to "myextension" works independently of the path it's located
>base URL is visited.
>Example for myplugin/index.php :
>$LocalAppDir = dirname(__FILE__);
>El 28/09/16 a les 13:16, Camilo Sperberg ha escrit:
>> __FILE__ (double underscore at beginning and end) is a constant which
>> 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?
>> On Wed, Sep 28, 2016 at 12:56 PM, Narcis Garcia
>>> 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?
>>> /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:
>>> 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
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
What's wrong with using one of the PSR autoloading methods for your plugin? That would be far more universal, as you could then treat it as any other plugin/module/tool installed with composer.
Also, please try not to to post, it breaks formatting for the web archive and goes against the list rules.
Sent from my Android device with K-9 Mail. Please excuse my brevity.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php