Home  >  Article  >  Backend Development  >  Summary of some of the most easily forgotten knowledge points in PHP_PHP Tutorial

Summary of some of the most easily forgotten knowledge points in PHP_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:11:19837browse

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 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

Copy code The code is as follows:

/* 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";
}


?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326912.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...
Statement:
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