PHP gets directories and methods through magic variables, through super global variables, through related functions and so on:

Source: Internet
Author: User

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:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.