On various pages throughout my PHP web site and in various nested directories I want to include a specific file at a path relative to the root.
What single command c
From the perspective of PHP root is the top of the file system on the web server, not the root from the perspective of the web browser.
Most people do one of the below.
Define a constant, in a global configuration file, and use that in each call to require/include.
Or they use code like this.
require_once realpath(dirname(__FILE__).'/config.php');
require_once realpath(dirname(__FILE__).'/lib/Database.php');
Using the environmental variables may be dangerous in some cases and be the source of security issues.