The PHP Request Root function returns the document root directory path of the current script. This function is useful when using relative paths for including other files, loading images or other resources.
Example 1: Suppose the PHP script is located in a folder called "my-folder" in the document root directory, and we want to include a file located in the parent folder of "my-folder". We can use the Request Root function to get the document root path and then navigate to the parent folder with relative path:
Example 2: Suppose we want to load an image located inside a folder named "images" in the document root directory. We can use the Request Root function to get the document root path and then append the relative path to the image:
";
?>
The Request Root function is a built-in PHP function and does not require any external package/library to be installed.
PHP Request::root - 30 examples found. These are the top rated real world PHP examples of Request::root from package someline-starter extracted from open source projects. You can rate examples to help us improve the quality of examples.