1<?PHP2 /**3 * PHP Get path or directory implementation4 * @link http://www.phpddt.com5 */6 7 //Magic variable to get the absolute path of the current file8 Echo"__FILE__: ========>".__file__; 9 Echo' <br/> ';Ten One //Magic variable, gets the directory of the current script A Echo"__dir__: ========>".__dir__; - Echo' <br/> '; - the //dirname Returns the directory portion of the path, DirName (__file__) is equivalent to __dir__ - Echo"DirName (__file__): ========>".dirname(__file__); - Echo' <br/> '; - + //the results of $_server[' php_self ' and $_server[' script_name '] are generally the same, they all get the file name of the current script - //Only when PHP is running in CGI mode, but now it's almost impossible to find a CGI run of PHP. + Echo' $_server[' php_self "]: ========> '.$_server[' Php_self ']; A Echo' <br/> '; at - Echo' $_server[' Script_name "]: ========> '.$_server[' Script_name ']; - Echo' <br/> '; - - //the absolute path of the current execution script. Remember that running PHP in the CLI mode is not available - Echo' $_server[' Script_filename "]: ========> '.$_server[' Script_filename ']; in Echo' <br/> '; - to //the document root directory where the script is currently running. Defined in the server configuration file. + Echo' $_server[' Document_root "]: ========> '.$_server[' Document_root ']; - Echo' <br> '; the * //GETCWD () returns the current working directory $ Echo"GETCWD (): ========>".GETCWD();Panax Notoginseng Echo' <br> '; - the Echo' <br> '; + Echo"PHP Point-to-point (www.phpddt.com) collation";
PHP gets directories and methods through magic variables, through super global variables, through related functions and so on: