I have a file myscript.php which works with lots of txt files by reading and modifing them.
My script is called by lots of other files from parent folder like:
c:/unknown_installation_path/parentfile.php -- includes myscript.php (i'm not allowed to modify them because of the parent script architecture)
c:/unknown_installation_path/project/my/myscript.php -- I can modify it.
sometimes surfers navigate to parent files (which include myscript.php) or sometimes they navigate to myscript.php directly.
Location of myscript is different on each server machine because of the installation path.
I work with myscript.php only and I need to know what is its current directory in both cases: when is it called directly and when it is called via an include from parent folder.
How can I do that? Obviously, I cannot use standard great function getcwd() because it returns different paths if my file is called via includes from parent folders.
Is there any permanent solution to it? Thanks.
what is the real working directory?
Moderator: General Moderators
Re: what is the real working directory?
I think you're looking for __FILE__ in the case of the include and $_SERVER['SCRIPT_FILENAME'] in the case of being called.
Here's an example with information about different server configurations:
http://www.bin-co.com/php/articles/curr ... e_path.php
Here's an example with information about different server configurations:
http://www.bin-co.com/php/articles/curr ... e_path.php