I have a file that connects to a database, database.php. I also have a file for defined constants, config.php, and it is stored in the top level directory because I'm going to use those constants on the main site and when I edit them, I don't want to edit two different files. So in database.php I added require_once('../../config.php'). Then, when I want to connect to the database in a particular file (home.php), I just add require_once('includes/database.php').
The problem I'm having is the path in the require_once('../../config.php') code in the database.php file breaks depending upon where the require_once('database.php') code is being called from, which is the case below:
It works if require_once('../../config.php') is instead require_once('../config.php'). Looks like when I require a file and that required file contains other required files, it uses the main file's directory path instead. I hope I explained my problem clear enough. To reiterate, I basically want the path to the config.php file (again called from the database.php file to be resolved automatically so I can require database.php from anywhere within the 'cpanel' directory.