PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
__FILE__
The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances.
There is a piece of software that, in order to have several instances of it, has to be installed multiple times. I am trying to make it so that multiple installations are actually symbolic link "directories" all pointing to the same code base. Then each "installation" can have its own config file in the parent directory of each symbolically linked "directory".
The software comes with the functionality that it looks in the parent directory (of an included file) for a config file. I want to try a multiple installation hack by altering just this one little piece of code that looks for the config file in the parent directory to instead make it look for the config file in the parent of the symbolic link if the "directory" is actually a symbolic link. Otherwise with one copy of the code base in one actual location accessed by different symbolic link "directories", the different "installations" would actually be looking at the same config file.
Does that make sense? I am trying to do a multiple installation hack with making the smallest and cleanest amount of changes to the original code.
The original poster has a really short description of a solution he came up with. I am wondering if someone here can help me decipher this:
I explode('/',__FILE__);
I then loop backwards through the array prepending a "relative path"
with the current explosion value.. until
realpath($_SERVER['DOCUMENT_ROOT'].'/'.$rel_path) == __FILE__