php absolute path code example
Example 1: php get file location
# C:\Users\Redacted\Desktop\main.php
include __DIR__ . DIRECTORY_SEPARATOR . 'include.php';
echoScriptPath();
# C:\Users\Redacted\Desktop\include.php
function echoScriptPath() {
list($scriptPath) = get_included_files();
echo 'The script being executed is ' . $scriptPath;
}
Example 2: php root path
$_SERVER['DOCUMENT_ROOT']
Example 3: absolute path php
// File in htdocs MAMP
echo getcwd(); //Users/Example/Applications/MAMP/htdocs
Example 4: php absolute value
abs ( mixed $number ) : number