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 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 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), 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;
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:
' = = 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.self:: The difference between the this-> and the
When accessing a member variable or method in a PHP class, if the referenced variable or method is declared as const (defining a constant) or static (declaring static), then the operator must be used::, conversely, if the referenced variable or method is not declared as const or static, Then you must use the operator---.
In addition, if you access a const or static variable or method from within a class, you must use self-referencing, and conversely, if accessing from within a class is not a const or static variable or method, you must use a self-referencing $this.
The difference between
8.strstr () and Strpos ()
stristr () is case-insensitive strstr () case-sensitive
function finds the position of the first occurrence of a string in another string. If successful, the
returns the remainder of the string (from the matching point). If the string is not found, false is returned. The
Stripos () case-insensitive strpos ()-Sensitive
function returns the position of the first occurrence of a string within another string. The
returns False if the string is not found. The
has been tested to show that Strpos () performs more efficiently than STRSTR () if only a simple lookup is present ()
9.PHP in Http_host and server_name
Same point:
The same information is output when the following three conditions are met.
1. Server is 80 port
2. ServerName is set correctly in Apache Conf
3. http/1.1 Protocol Specification
Different points:
1. The usual situation:
_server["Http_host"] under the http/1.1 protocol specification, the information is output based on the HTTP request of the client.
_server["SERVER_NAME"] by default, the ServerName value in the Apache configuration file httpd.conf is output directly.
2. When the server is not 80 ports:
_server["Http_host"] outputs the port number, for example: mimiz.cn:8080
_server["SERVER_NAME"] will output servername value directly
So in this case, it can be understood as: Http_host = Server_name:server_port
3. When servername in profile httpd.conf is inconsistent with the domain name requested by http/1.0:
The httpd.conf configuration is as follows:
ServerName mimiz.cn
Serveralias www.mimiz.cn
Client Access domain name www.mimiz.cn
_server["Http_host"] Output www.mimiz.cn
_server["SERVER_NAME"] Output mimiz.cn
Therefore, in the actual procedure, should try to use _server["Http_host", more insurance and reliable.
If in the case of port mapping and access in the Intranet, "$_server[' Http_x_forwarded_host '" is better.
http://www.bkjia.com/PHPjc/327788.html www.bkjia.com true http://www.bkjia.com/PHPjc/327788.html techarticle the difference between 1.echo and print is basically the same for Echo and print in PHP (output), but there are subtle differences between the two. There is no return value after the echo output, but print has a return value when it is ...