Summary of some of the most easily forgotten knowledge points in PHP _ php instances

Source: Internet
Author: User
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 ";


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.