For example: the program root directory is in: E:wampwww
1. __FILE__ The absolute path of the current file
If called in index.php, it will return E:wampwwwindex.php
Let’s take a look at the directory structure of the program root directory
If __FILE__ is called in c_system_base.php it returns:
E:wampwwwzb_systemfunctionc_system_base.php
2.dirname Returns the parent directory of the current directory or the directory where the current file is located (without / at the end)
Generally used in conjunction with __FILE__
If dirname(__FILE__) is called in c_system_base.php, it will return
E:wampwwwzb_systemfunction (the file returns to the directory where it is located)
If dirname(dirname(__FILE__)) is called, it returns
E:wampwwwzb_system (the directory returns to the upper directory)
realpath() method returns the absolute path of the current file or the path relative to the root directory
If realpath(__FILE__) is called in c_system_base.php, it will return
E:wampwwwzb_systemfunctionc_system_base.php
realpath('/') Return to disk root directory E:
realpath('./') Return to the root directory E:wampwww
realpath('../') Returns the superior directory relative to the program root directory
can also be used in conjunction with dirname, usually adding several relative paths../ (add / in front, that is: /../)
realpath(dirname(__FILE__)) Return E:wampwwwzb_systemfunction
realpath(dirname(__FILE__).'/../') returns E:wampwwwzb_system
realpath(dirname(__FILE__).'/../../') Return E:wampwww