This article mainly introduces how to abbreviate IF judgment in PHP, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
The first type: IF conditional statement
Second type: ternary operation
Third type: conditional statement composed of && and ||
First type: IF Needless to say, this is the basis, I believe it Most people will;
Second: c=a>b? true:false //Means: If a>b is true, return true, otherwise return false (of course it can be replaced with a statement) , And return the result to C;
3:
1, &&
## In most languages, he means and of Both sides are true, using PHP as an example, it is used in the tradition;if ($a>0 && $b>0){ //语句; }
if ($a>0){ $b='This is test'; }
Explanation of string functions in PHP
Introduction
How to solve the problem of php in Array reference problem left after foreach loop
The above is the detailed content of How to abbreviate IF judgment in PHP. For more information, please follow other related articles on the PHP Chinese website!