Parse the constants of php dirname of and ___

  • 2020-06-19 09:54:07
  • OfStack

Per 0en__, 1en (2en__), basename(4en__), dirname(6en__)."/f/".basename(9en__), and the file name of the f in each ___, is called dirname(12en__) and require contains the document to that.
Here are the details:
1) The dirname(___ 17en__) function returns the path the script is on.
For example, b. php contains the following:
< ?php
$basedir = dirname(__FILE__);
? >
If b.php is referenced by the a.php file require or include in another directory.
The contents of the variable $basedir are also the path to the folder in which b.php resides.
Instead of becoming the directory where the a.php file resides.

2) dirname(46EN__) 1 will normally return the current directory of the file to the system root.
Does not return the current file name.
dirname(50EN__) may also return 1. (current directory)
The reason is that the ES52en.php file is in the default WEB directory of the ES54en.conf or PHP configuration development environment.
For example, WEB_ROOT: "C:/root/www/".
b. php file path for: "C: / root www/b php".

3) Usage tips,
If you repeat it once, you can move it up one level:
$d = dirname(dirname(___));
You're just giving a directory to dirname(). Because dirname() returns the last directory without \ \ or is /
So when you reuse, think of dirname() as treating the lowest directory as the file name. Return as usual
The parent directory of the current directory. This repetition results in its previous level 1 directory.

4) Contains files that get the previous level 1 directory
include(dirname(__FILE__).''/../filename

Related articles: