I need a require_once file, which is located in the root directory of my sites. The problem is that I will not always know how many levels of the root directory are located where the current current script is running. So I need to find out how many directory levels I need to find in the require_once file.
Sometimes it can be:
require_once '../../file.php';
And sometimes it can be:
require_once '../file.php';
Or any other number of directory levels.
How can I calculate how much "../" I need to get to the root directory from anywhere in the subdirectory?
source share