getRoot is a function in PHP that returns the root directory of the PHP script currently being executed. It retrieves the root directory as an absolute path string.
Example 1:
Suppose we have a PHP file located at `/var/www/html/example.php`. To get the root directory of the script, we can use the following code:
This will output `/var/www/html`.
Package/library: PHP core language.
Example 2:
Suppose we have a project with a directory structure like this:
To get the root directory of the project, we can use the following code in the `functions.php` file:
This will output `/var/www/html/Project`.
Package/library: Not applicable in this example as it is a basic file system operation.
PHP Lang::getRoot - 17 examples found. These are the top rated real world PHP examples of Lang::getRoot from package someline-starter extracted from open source projects. You can rate examples to help us improve the quality of examples.