php if 写法有哪些

php if 写法有哪些,第1张

php if 写法有哪些

php if写法有5种,分别是:1、“if {...}else {...}”;2、“if () :...else:...endif;”;3、“...? true : false;”;4、“if ()...”;5、“...&&...”。

本文 *** 作环境:windows7系统、PHP7.1版、DELL G3电脑

php if 写法有哪些?

PHP中if语句5种写法

代码如下:

<?php
    // one
    if (condition) {
        ...
    } else {
        ...
    }
    // two
    if (condition) :
        ...
    else:
        ...
    endif;
    // three
    condition ? true : false ;
    // four if后面紧接着判断为true所执行的代码,可分两行写,只有一个分号
    if (condition) ... ;
    //five 使用短路与和短路或
    expression1 && expression2;
    expression1 || expression2;

推荐学习:《PHP视频教程》

以上就是php if 写法有哪些的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/langs/681466.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-04-20
下一篇2022-04-20

发表评论

登录后才能评论

评论列表(0条)

    保存