This article summarizes some of the most easily forgotten knowledge points in PHP. For more information, see
1. Define constants:
The Code is as follows:
// 1
Define ("TAX_RATE", 0.08 );
Echo TAX_RATE; // output 0.08
// 2 (PHP 5.3)
Const TAX_RATE2 = 0.01;
Echo '--'. TAX_RATE2; // output 0.01
?>
2. Difference Between require and require_once:
If a file is contained, the former determines whether the file has been included. If yes, the former does not include the file. One can save resources, and the other can avoid repeated definition errors.
3. Differences between include and include_once:
Both functions and functions can include a page to another page. The former can contain multiple times, and the latter can only contain once.
4. Differences between include and require (include_once and require_once)
Same: Other pages can be introduced.
Different: if an error occurs in include, it will continue to be executed. If require encounters an error, the program will be terminated.
Conclusion: require_once is basically used for the project and written at the beginning of PHP.
5. variables defined in PHP are case-sensitive, and functions are case-insensitive.
The Code is as follows:
/* Define variables to be case sensitive */
$ Abc = 100;
$ Abc = 200;
Echo $ abc. '|'. $ Abc; // output 100 | 200
/* If the definition function is case-insensitive, the system reports an error: Fatal error: Cannot redeclare Abc ()*/
Function abc (){
Echo 'abc ';
}
Function Abc (){
Echo "Abc ";
}
?>