Some of the most easily forgotten knowledge points in PHP summary _php instance

Source: Internet
Author: User

1. Define constants:

Copy Code code as follows:

<?php

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, Require and require_once difference:

The former encounters the inclusion file, which determines whether it has already been included, and if it is included, no longer contains the file. One can save resources and two can avoid repeated definitions of errors.

3, include and include_once the difference:

Functions and functions can be a page, included to another page, the former can contain many times, the latter contains only once.

4, include and require distinction (meanwhile include_once and require_once)

Same: All can be introduced to other pages

Different: Include if an error occurs, the execution continues, and require an error occurs, the program is terminated.

Conclusion: When doing the project, we basically use require_once and write it in front of PHP.

5, the definition of variables in PHP is case-sensitive, defining the function when the case is not case-sensitive

Copy Code code as follows:

<?php

/* Define variable case sensitivity *
$ABC = 100;
$ABC = 200;

echo $abc. ' | '. $ABC; Output 100|200

/* Definition function is not case-sensitive the following writing system will 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: info-contact@alibabacloud.com 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.