Today saw the caterpillar to make an empty string and a null distinction (http://bbs.phpchina.com/thread-99574-1-2.html), I feel that the basic knowledge is not solid birds (such as me) very helpful, late at night, for a while, looked at a lot of "Authoritative information" to write an article posted here and everyone together to cram the basic knowledge, of course, my title is not rigorous, the content is only a personal summary, the shortcomings of the master to add more, words do not say much, the text is as follows:
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."
Code:
$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:
Code:
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:
Code:
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 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 will find that they print out is a string and null, of course, 0 is also easy to confuse , you can try Echo GetType (0); If you print the type, you will find that the 0 type is an integer (integer), the visible string (), NULL, and 0 are "equivalent" but unequal types.
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:
Code? :
$id = 0;
Empty ($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:
Code:
= = 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.
http://www.bkjia.com/PHPjc/486605.html www.bkjia.com true http://www.bkjia.com/PHPjc/486605.html techarticle today, I saw a caterpillar that made an empty string and a null distinction (http://bbs.phpchina.com/thread-99574-1-2.html), and I felt that a bird (like me) with a basic knowledge was very helpful ...