Basic tutorial: Differentiation of obfuscation functions in PHP

Source: Internet
Author: User
Basic tutorial: PHP obfuscation function distinction, read basic tutorial: PHP obfuscation function distinction, today saw the Caterpillar for everyone to do a NULL string and NULL distinction (http://bbs.phpchina.com/thread-99574-1-2.html ), I feel very helpful to birds with poor basic knowledge (such as me). I am very interested in it late at night. I checked a lot of "permissions"> <LINKhre

Today I saw the Caterpillar made a distinction between NULL string and NULL for everyone (http://bbs.phpchina.com/thread-99574-1-2.html), I feel very helpful to the basic knowledge of the birds (such as me), late at night, a moment of interest, I checked a lot of "authoritative materials" and wrote an article here to help you with the basic knowledge. of course, my title is not rigorous, and the content is just a personal summary, if you have any shortcomings, please add them as follows:

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.
Code:

$ 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:
Code:

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

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:
Code? :

$ Id = 0;
Empty ($ 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:
Code:

''= 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.