The 1,define () function defines a constant. Constants are similar to variables, except that:
(1) After setting, the value of the constant cannot be changed
(2) The constant name does not need to start with the dollar sign ($)
(3) Scope does not affect access to constants
(4) A constant value can only be a string or a number
Grammar
Define (name,value,case_insensitive)
Name, required, specifying constant names; value, required, specified constant value; case_insensitive, optional. Specifies whether the name of the constant is case sensitive. The default is False (case sensitive).
instance, defines a case-sensitive constant and outputs
Define (' STR ', ' Hello World '); Echo STR;
Output Hello World
2,dirname (__file__)
DirName (__file__) is the absolute path to the current file, and the lookup speed is the fastest compared to the relative path.
If you repeat the dirname once, you can raise the directory up one level:
The example below assumes that the test.php file is stored in the (d:\www\) directory
echo __file__; Obtain the current file absolute address, output D:\www\test.php echo dirname (__file__);//Get the absolute directory where the current file is located, output D:\www echo dirname (dirname (__ file__));//Gets the previous level of the directory where the current file is located, Output D:
PHP define () and dirname (__file__)