dirname(DIR); returns the parent of the current directory.
I would like the secure path above the document root:
// current working directory
echo getcwd(); // /home/john/www/test/current-working-path
// parent directory of current directory
echo dirname(__DIR__); // /home/john/www/test
// document root
echo $_SERVER["DOCUMENT_ROOT"]; // /home/john/www
// secure path required above the document root
// /home/john/
// confidential information not available to public
$dbConf = "/home/john/_dbParams.php";
I have used that and found it was trial and error to gradually add …/ until I hit upon the correct path. It also fails if the path is moved to a different level whereas this works every time:
Given a string containing the path of a file or directory, this function will return the parent directory’s path that is levels up from the current directory.
Yeah, one of the things that hurts PHP as a language in my opinion is the naming of functions. I am not sure why some function names are what they are.