Home > Backend Development > PHP Tutorial > Sharing of PHP knowledge points that are easy to forget_PHP Tutorial

Sharing of PHP knowledge points that are easy to forget_PHP Tutorial

WBOY
Release: 2016-07-21 15:11:35
Original
899 people have browsed it

1. Define constants:

Copy code 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. The difference between require and require_once:

The former includes the file when it encounters it, and the latter will determine whether it has been included If it has been included, the file will no longer be included. First, it can save resources, and second, it can avoid errors of repeated definitions.

3. The difference between include and include_once:

Both 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: both can introduce other pages

Difference: include will continue to execute if an error occurs , 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

Copy code The code is as follows:

/* Defining variables is 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 you write it below: Fatal error: Cannot redeclare Abc() */
function abc(){
echo 'abc';
}
function Abc(){
echo "Abc";
}
?>


6. In mysql During installation, set the character set to UTF-8, and Chinese data added to the table on the mysql client (the interface entered by cmd) cannot be added to the database. Just set it as follows:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326886.htmlTechArticle1. Define constants: Copy the 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 ?...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template