admin 发表于 2023-2-16 18:54:54

PHP中的if else 和elseif and else if

<div id="article_content" class="article_content clearfix">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
      <link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-6e43165c0a.css">
                <div id="content_views" class="htmledit_views">
                  <pre><code>//if语句书写
<?php
if ($a > $b)
echo &#34;a is bigger than b&#34;;
?>

//else语句的书写
<?php
if ($a > $b) {
echo &#34;a is greater than b&#34;;
} else {
echo &#34;a is NOT greater than b&#34;;
}
?>

//elseif/else if语句书写
<?php
if ($a > $b) {
    echo &#34;a is bigger than b&#34;;
} elseif ($a &#61;&#61; $b) {
    echo &#34;a is equal to b&#34;;
} else {
    echo &#34;a is smaller than b&#34;;
}
?></code></pre>
<p></p>
                </div>
      </div>
      <div id="treeSkill"></div>
页: [1]
查看完整版本: PHP中的if else 和elseif and else if