-
<?php
-
/**
-
* PHP access path or directory implementation
-
*/
-
-
//Magic variable, get the absolute path of the current file
-
echo "__FILE__: ========> ".__FILE__;
-
echo '<br/>';
-
//Magic variable, get the directory of the current script
-
echo "__DIR__: ========>" .__ DIR__;
-
echo '<br/>';
-
//dirname returns the directory part of the path, dirname(__FILE__) is equivalent to __DIR__
-
echo "dirname(__FILE__): ========> ".dirname(__FILE__);
-
echo '<br/>';
-
//$_SERVER['PHP_SELF'] and $_SERVER['SCRIPT_NAME'] generally have the same result, they both get the file name of the current script
-
//There is a difference only when php runs in cgi mode, but now it is almost impossible to run php in cgi mode
-
echo '$_SERVER["PHP_SELF"]: ========> '.$_SERVER['PHP_SELF'];
-
echo '<br/>';
-
echo '$_SERVER["SCRIPT_NAME"]: ========> '.$_SERVER['SCRIPT_NAME'];
-
echo '<br/>';
-
//The absolute path of the currently executing script. Remember, it is not available to run php in CLI mode
-
echo '$_SERVER["SCRIPT_FILENAME"]: ========> '.$_SERVER['SCRIPT_FILENAME'];
-
echo '<br/>';
-
//The document root directory where the currently running script is located. Defined in the server configuration file.
-
echo '$_SERVER["DOCUMENT_ROOT"]: ========> '.$_SERVER['DOCUMENT_ROOT'];
-
echo '<br>';
-
//getcwd() returns the current working directory
-
echo "getcwd(): ========> ".getcwd();
-
echo '<br>';
-
echo '<br>';
-
echo "PHP Finishing";