Explicit file path to parent directory

I have a situation where I have two configuration files.
The basic configuration, which is in the parent directory, and the sibling configuration in the sibling directory.
Today, the sibling looks at the parent with a simple

require_once "../parent_config.php"; 

However, now I want to transfer my brother to the new class system. I can pass the explicit path to the sibling file without problems, but I obviously ran into problems with the above call to my parents.
I am trying to do something along the line of the following, but I am mistaken somewhere (I am trying to say that there is one explicit path to the file)

 require_once (dirname(__FILE__) . "../parent_config.php"); 

I would appreciate your comments.
Thanks
Giles

+4
source share
1 answer

Try

 require_once realpath(dirname(__FILE__).'/..').'/parent_config.php'; 

Or for PHP 5.3+

 require_once realpath(__DIR__.'/..').'/parent_config.php'; 

Or even just old, this should work ...

 require_once __DIR__.'/../parent_config.php'; 
+19
source

All Articles