PHP function and server variable to obtain the current url path:
Code:
Copy code The code is as follows:
$path = /usr/opt/../ect/abcd;
echo $_SERVER['DOCUMENT_ROOT']."
"; //Get the server document Root variable (depends on the configuration in http.conf)
echo $_SERVER['PHP_SELF']."
"; //Get the path to the file that executes the code, which is consistent with the configuration in http.conf relation.
echo __FILE__."
"; //Variable to get the file system absolute path of the file
echo dirname(__FILE__); //Function to get the folder path where the file is located
echo realpath( $pah);
?>
Returned value:
Copy code Code As follows:
/usr/opt/apache2/htdocs/
/alias/aa.php
/usr/opt/apache2/htdocs/kamap/aa.php
/ usr/opt/apache2/htdocs/kamap/
/usr/etc/abcd
http://www.bkjia.com/PHPjc/327929.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327929.htmlTechArticlePHP functions and server variables to obtain the current url path: Code: Copy the code as follows: ?php $path = / usr/opt/../ect/abcd; echo $_SERVER['DOCUMENT_ROOT']."br"; //Get the server document...