Simply summarize the differences between Echo () and the easy-to-confuse functions like print (), require (), and include ()
The difference between 1.echo and print
The functions of Echo and print in PHP are basically the same (output), but there are subtle differences between the two. There is no return value after the echo output, but print has a return value and returns Flase when its execution fails. It can therefore be used as a normal function, such as executing the following code after the variable "value will be 1."
$r = print "Hello world";
This means that print can be used in some complex expressions, while Echo is not. However, because the Echo statement does not require any values to be returned, the Echo statement in the code is running more efficiently than the print statement.
The difference between 2.include and require
The features of include () and require () are basically the same (included), but there are some differences in usage, including that include () is a conditional include function, and require () 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 ($a) { include ("a.php"); }
and require () is different from include (), no matter what the value of $ A, the following code will include the file a.php into the file:
if ($a) { require ("a.php"); }
In the case of error handling, the include statement is used, and if an error occurs, the program skips the include statement, although an error message is displayed but the program will continue to execute! But Requre will give you a fatal mistake.
Of course, we can also understand the literal meaning of seven points: Requre is a very tough request, the meaning of the request.
3.require_once () and include_once () statements
Off-topic, because of the long image, the simple require_once () and include_once () statements correspond to the require () and the Include () statements respectively. The require_once () and include_once () statements are primarily used when you need to include multiple files, and you can effectively avoid errors where the same piece of code is included in a function or variable that is repeatedly defined.
4. The difference between an empty string (") and a null
PHP hollow strings and null are stored with a value of 0, but they are not the same type, you can try Echo GetType ("); and Echo gettype (NULL); you'll find that they print out string and null, Of course 0 is also easy to confuse, you can try Echo GetType (0), print the type, you will find that the type of 0 is an integer (integer), the Visible string ("), null and 0 are" equivalent "but unequal type.
The difference between 5.isset and empty
From the literal meaning we can understand: empty is to determine whether a variable is "empty", and isset is to determine whether a variable has been set. But here's a point to be sure: when a variable value of 0,empty thinks the variable equals null, that's equivalent to no setting. For example, when we detect the $id variable, when $id=0, with empty and isset to detect whether the variable $id is configured, both will return different values: Empty is not Configured, isset can get $id value, see the following example:
$id = 0;
Emptyempty ($id)? print "I am Empty":p rint "I am $id."; Result: I'm empty.
!isset ($id)? print "I am Empty":p rint "I am $id."; /Result: I am 0
The difference between 6.== (ET) and = = = (identity)
Looking back at the difference between the fourth empty string ("") and null, let's look at an example:
"= = NULL;
"= = = NULL;
After running you will find that the first one is true and the second is false! Visible = = is only the comparison value is equal, and = = = Not only compare values, but also compare the type, more stringent.