First type: IF condition statement
The second type: three mesh operation
The third kind of:&&, | | Conditional statements made up of
The first kind: IF do not say, this is the foundation, I believe most people will;
The second kind: C=a>b? True:false//means: If the a>b is true then return true, otherwise return false (of course, can be replaced with a statement), and return the result to C;
The third type:
1. &&
In most languages, he means and meaning, that is, the left and right sides are true, using PHP as an example, traditionally used;
if ($a >0 && $b >0) { //statement;}
Execute the statement when both are true;
Today, however, we use him as a conditional statement, for example there is a traditional conditional statement at the bottom:
if ($a >0) {
$b = ' This is test ';
}
The statement is executed when the condition is true, but it is too cumbersome to write, so we can write it directly:
$a >0 && ($b = ' This is test ');
The computer will first determine whether a $ A is true, if it is, then execute the following statement, if no, the subsequent statement will not be necessary to execute;
Benefits: 1, can be written in one line,
2, omit the code;
2, | |
Unexpectedly && can write conditional statements like this, then | | Of course, it is possible, but his order of execution is not the same.
$a >0 | | ($b = ' This is test ');
The computer first determines whether a $ A >0 is true, is: The following statement will not execute, no: execute;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The above describes the use of && PHP written conditional statements-three conditional statements, including aspects of the content, I hope to be interested in the PHP tutorial friends helpful.