Home > Article > Backend Development > Summary of some of the most easily forgotten knowledge points in PHP_PHP Tutorial
1. Define constants:
//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
?>
The former will include the file when it encounters it, and the latter will determine whether it has been included. If so, it will no longer include the file. First, it can save resources, and second, it can avoid errors of repeated definitions.
3. The difference between include and include_once:
Both functions and functions can include one page into another page. The former can be included multiple times, while the latter can be included only once.
4. The difference between include and require (include_once and require_once at the same time)
Same: you can import other pages
Different: if an error occurs in include, execution will continue, while if an error occurs in require, the program will be terminated.
Conclusion: When working on a project, basically use require_once and write it at the front of PHP.
5. Variables defined in PHP are case-sensitive, but functions are not case-sensitive
/* Define variables to be case-sensitive*/
$abc=100;
$Abc=200;
echo $abc.'|'.$Abc; //Output 100|200
/* The defined function is not case-sensitive. The system will report an error if written below: Fatal error: Cannot redeclare Abc() */
function abc(){
echo 'abc';
}
function Abc(){
echo "Abc";
}
?>