Summary of some of the most forgotten facts in PHP

  • 2020-06-01 08:37:27
  • OfStack

1. Define constants:

    echo TAX_RATE;  // The output 0.08
    //2 (PHP 5.3)
    const TAX_RATE2 =0.01;
    echo '--'.TAX_RATE2; // The output 0.01

2. Differences between require and require_once:

The former contains the file when it is encountered, and the latter determines whether it has already been included. If it has, it no longer contains the file. 1 can save resources and 2 can avoid the error of repeating definitions.

3. Differences between include and include_once:

Functions and functions can include one page into another page, the former multiple times, the latter only once.

4. Difference between include and require (include_once and require_once at the same time)

Same: both can be introduced to other pages

Difference: include will continue execution if an error occurs, and require will terminate the program if an error occurs.

Conclusion: when working on a project, require_once is basically used and written first on PHP.

5. Variables are case sensitive in PHP, and functions are not case sensitive when they are defined

    /*  Define variables that are case sensitive */
    echo $abc.'|'.$Abc; // The output 100|200
    /* Define functions that are case insensitive   The following notation system will report an error :Fatal error: Cannot redeclare Abc() */
    function abc(){
        echo 'abc';

    function Abc(){
        echo "Abc";


Related articles: