The __FILE__ and dirname() functions have been enabled since PHP 4.0.2.
__FILE__ indicates the absolute path of the current file including the file name, such as D:\WWW\WWW\BLOG\controllers\AbcController.php
basename(__FILE__) indicates the file name (including the extension) of the current file, such as AbcController.php
The dirname() function returns the directory part of the path (representing the absolute path of the current file)
dirname(__FILE__); generally returns a directory structure from the current directory where the file is located to the system root directory, that is, the directory name of the layer where the file is located, and does not return the current file name. Such as D:\WWW\WWW\BLOG\controllers
If it is repeated once, the directory can be raised one level: for example: $d = dirname(dirname(__FILE__));
In fact, it is to pass a directory to dirname() as a parameter. Because dirname() returns the last directory without \ or /,
So when reused, it can be considered that dirname() treats the lowest directory as a file name. Return to current as usual
The parent directory of the directory. Repeat this to get the directory above it. Such as D:\WWW\WWW\BLOG
The __DIR__ variable is newly added in PHP5.3.0 to get the absolute path of the directory where the current PHP file is located, such as D:\WWW\WWW\BLOG\controllers
So, if your PHP version is greater than or equal to PHP5.3.0, it is recommended to use __DIR__. Otherwise, it is better to use dirname(__FILE__) to ensure that the program does not fail.