Home > Backend Development > PHP Tutorial > Examples of functions and server variables for PHP to obtain the current url path

Examples of functions and server variables for PHP to obtain the current url path

WBOY
Release: 2016-07-25 08:58:09
Original
1024 people have browsed it
  1. $path = /var/www/../ect/abcd;
  2. echo $_SERVER['DOCUMENT_ROOT']."
    "; //Get the server document root variable ( Depends on the configuration in http.conf)
  3. echo $_SERVER['PHP_SELF']."
    "; //Get the path to the file that executes the code, which is related to the configuration in http.conf.
  4. echo __FILE__."
    "; //Variable to get the file system absolute path of the file
  5. echo dirname(__FILE__); //Function to get the path of the folder where the file is located
  6. echo realpath($pah);
  7. ? >
Copy the code

Output results:

/var/www/htdocs/ /alias/aa.php /var/www/htdocs/kamap/aa.php /var/www/htdocs/kamap/ /usr/etc/abcd


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template