Home > Article > Backend Development > What are the ways to write php if
php There are 5 ways to write if, namely: 1. "if {...}else {...}"; 2. "if () :...else:...endif; "; 3. "...? true : false;"; 4. "if ()..."; 5. "...&&...".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What are the ways to write php if?
5 ways to write if statements in PHP
The code is as follows:
<?php // one if (condition) { ... } else { ... } // two if (condition) : ... else: ... endif; // three condition ? true : false ; // four if后面紧接着判断为true所执行的代码,可分两行写,只有一个分号 if (condition) ... ; //five 使用短路与和短路或 expression1 && expression2; expression1 || expression2;
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What are the ways to write php if. For more information, please follow other related articles on the PHP Chinese website!