Sometimes I learn a lot, a lot of small details are forgotten, such as simple expression,
Three-dimensional expression?:;
$aa an OR $BB expression
Wait a minute!
Write some simple expressions, Memo!
php && | | Abbreviation CONDITION statement
Look at the following notation:
<? PHP! $var $var = ' Hello! '; $error die (' error! ');? >
&& is the simultaneous true operator.
A && B, this is true only if both A and B are true.
PHP will first determine if a is true, and if A is true, it will continue to judge B.
So, when a is true and B is a statement, B runs.
Similarly, when a is false, this sentence must be false, there is no need to judge the future, at this time, B will not run.
|| Or is different
A or B, as long as there is one in a or B is true, this sentence is true
PHP first to determine whether a is true, if a is true, this sentence must be true, there is no need to judge B
So when a is false, PHP will continue to judge whether B is true, to get the result of this sentence
This is, B, if it is a statement, it will run.
Remember that data connection at the beginning of the entry? It should be understood now, why add an OR?
[PHP] mysql_connect ($host,$user,$pwddie ('Mysql error!'); [/php]
If the connection fails, the front is false, the back die will run!
Let's look at the following example:
[PHP] $var = ";! $var Echo "It's empty!" ";! $var Print "It's empty!" "; [/php]
which can be executed successfully?
You know why?
Here is the difference between echo and print:
The difference between Echo and print
The functions of ECHO and print are basically the same in PHP, but there are subtle differences between the two. In PHP code, print can be used as a normal function, for example, after executing the following code, the value of the variable $res will be 1.
1 |
<li>ret = print \ "Hello World \"; </li> |
This means that print can be used in some complex expressions, while Echo is not. Similarly, the Echo statement runs slightly faster than the print statement in the code, because the Echo statement does not require any values to be returned.
PHP shorthand expression,&& or | | Abbreviation CONDITION statement