The difference and usage summary of PHP's easy obfuscation function

Source: Internet
Author: User

Tags: Perform under compare confuse EXT business including display analysis

This paper analyzes the difference and usage of PHP's easy obfuscation function. Share to everyone for your reference. The specific analysis 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."

PHP Code:

Copy CodeThe code is as follows: $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:

PHP Code:

Copy CodeThe code is as follows: 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:

PHP Code:

Copy CodeThe code is as follows: 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 continues! But Requre will give you a fatal error.
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:

PHP Code:

Copy CodeThe code is as follows: $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:

PHP Code:

Copy CodeThe code reads: "= = NULL;
"= = = NULL;


After running you will find that the first 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.

7. The difference between PHP functions and methods

I always thought it was one thing, until I read the thinkphp document, there are functions and methods of the specification, just know that is not the same.

A method is a "function" in a class that can only be called through an object,
In particular, a static method of a class can be called directly through the class name.
The usual function, which should be a function in the global scope, can be called directly from anywhere after introduction.

Making a simple distinction is:
Functions are separate, which is defined in the process-oriented part.
Methods are dependent on the existence of a class, which is defined in object-oriented.

function, you can implement it as an algorithm.
method, it can be implemented as a business logic.

The method of the class can set access permissions, need to be called through an object or class, and the function is public and can be used.

The difference and usage summary of PHP's easy obfuscation function

Related Article

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.

Tags Index: