1. Differences between echo and print
The echo and print functions in PHP are basically the same (output), but there are still slight differences between the two. No return value after echo output, but print has a return value. If the execution fails, flase is returned. Therefore, it can be used as a common function. For example, after the following code is executed, the value of $ r is 1.
$ R = print "Hello World ";
This means that print is available in some complex expressions, but echo is not. However, because the echo statement does not require any value to be returned, the running efficiency of the echo statement in the Code is slightly faster than that of the print statement.
2. Differences between include and require
The include () and require () functions are basically the same (include), but there are also some differences in usage. include () is a conditional include function, while require () it is an unconditional include function. For example, in the following code, if the variable $ a is true, it will contain the file a. php:
If ($ ){
Include ("a. php ");
}
The require () is different from include (). No matter what the value of $ a is, the following code will include file a. php into the file:
If ($ ){
Require ("a. php ");
}
For error handling, use the include statement. If an include error occurs, the program skips the include statement. Although the error message is displayed, the program continues to execute! But requre will give you a fatal error.
Of course, we can also understand the literal meaning of 7 points: requre is a very tough request and requirement.
3. require_once () and include_once () Statements
Because of the long image, simple require_once () and include_once () Statements correspond to the require () and include () statements respectively. The require_once () and include_once () statements are mainly used to avoid repeated function or variable definition errors when you need to include multiple files.
4. Differences between NULL strings ('') and NULL
PHP empty strings and NULL are both stored with 0 values, but their types are not the same. You can try echo gettype (''); and echo gettype (NULL ); you will find that the printed values are string and NULL, and of course there are also 0 which are easy to confuse. You can try echo gettype (0); print the type, the type of 0 is integer (integer). It can be seen that the string (''), NULL, and 0 are" equivalent "but not equal to the type.
5. Differences between isset and empty
Literally, we can understand that empty is used to determine whether a variable is "null", while isset is used to determine whether a variable has been set. However, when the value of a variable is 0, empty considers the variable to be null, that is, it is equivalent to no setting. For example, when we detect the $ id variable, when $ id = 0, empty and isset are used to check whether the variable $ id has been configured. Both of them return different values: empty considers that there is no configuration, and isset can get the value of $ id. See the following example:
$ Id = 0;
Emptyempty ($ id )? Print "I am empty": print "I am $ id."; // result: I am empty
! Isset ($ id )? Print "I am empty": print "I am $ id."; // result: I am 0
6. Differences between = (wait) and = (constant)
Let's review the difference between the fourth NULL String ("") and NULL. Let's look at an example:
''= NULL;
''= NULL;
After running, you will find that the first is true, and the second is false! It can be seen that = only compares whether the values are equal, while = compares not only the values, but also the types and stricter.