? For example: The program root directory in: E:\wamp\www
1. __file__ the absolute path to the current file
Returns E:\wamp\www\index.php if called in index.php
Now look at the directory structure of the program root directory
If you call __file__ in c_system_base.php, it returns:
E:\wamp\www\zb_system\function\c_system_base.php
2.dirname returns the parent directory of the current directory or the directory where the current file is located (end without/)
Generally used in conjunction with __FILE__
If you call DirName (__file__) in c_system_base.php, it returns
E:\wamp\www\zb_system\function (text to return to the directory)
returns if DirName (DirName (__file__)) is called
E:\wamp\www\zb_system (directory returned to parent directory)
The Realpath () method returns the path to the absolute path or relative root of the current file
If you call Realpath (__file__) in c_system_base.php, it returns
E:\wamp\www\zb_system\function\c_system_base.php
Realpath ('/') returns the disk root directory E:\
Realpath ('./') returns the root directory E:\wamp\www
Realpath ('.. /') returns the parent directory relative to the program root directory
You can also use dirname with a few relative paths. /(before adding/i.e.:/.) /)
Realpath (DirName (__file__)) return E:\wamp\www\zb_system\function
Realpath (DirName (__file__). ' /.. /') return E:\wamp\www\zb_system
Realpath (DirName (__file__). ' /.. /.. /') return E:\wamp\www
PHP path-related dirname,realpath,__file__