Look, I’m having a problem using the file_exists() function.
I have this include.php file which many pages are including [/index.php, /admin/index.php, etx] But inside this include.php file I have to check if a file exists.. The thing is that I don’t know from which file include.php is being included.. So if I would have this:
include.php (in root directory)
[code=php]
if (file_exists(“install.php”)) {
echo “It exists”;
} else {
echo “It does not exist!”;
}
index.php (in root directory and install.php exists in the same directory)
[code=php]
include(“include.php”); //Will echo “It exists”
/admin/index.php (in /admin/ directory and no install.php exists in the same directory)
[code=php]
include(“../include.php”); //Will echo “It does not exist!”
As you see, the function file_exists() does not began lookin in the directory in which the script that is calling it is located; but in the directory where the main script (the one that does the include) is located..
What can I do to make the function began lookin in the directory where include.php is? Thanks!