⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control-structures.if.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>if</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.control-structures.html">Control Structures</a></div> <div class="next" style="text-align: right; float: right;"><a href="control-structures.else.html">else</a></div> <div class="up"><a href="language.control-structures.html">Control Structures</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="control-structures.if" class="sect1">   <h2 class="title"><i>if</i></h2>   <p class="para">    The <i>if</i> construct is one of the most important    features of many languages, PHP included.  It allows for    conditional execution of code fragments.  PHP features an    <i>if</i> structure that is similar to that of C:    <div class="informalexample">     <div class="example-contents"><div class="cdata"><pre>if (expr)    statement</pre></div>     </div>    </div>   </p>   <p class="simpara">    As described in <a href="language.expressions.html" class="link">the section about    expressions</a>, <span class="replaceable">expression</span> is evaluated to its    Boolean value.  If <span class="replaceable">expression</span> evaluates to <b><tt>TRUE</tt></b>,    PHP will execute <span class="replaceable">statement</span>, and if it evaluates    to <b><tt>FALSE</tt></b> - it&#039;ll ignore it. More information about what values evaluate    to <b><tt>FALSE</tt></b> can be found in the <a href="language.types.boolean.html#language.types.boolean.casting" class="link">&#039;Converting to boolean&#039;</a>    section.   </p>   <p class="para">    The following example would display <span class="computeroutput">a is bigger    than b</span> if <var class="varname">$a</var> is bigger    than <var class="varname">$b</var>:    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">)<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"a&nbsp;is&nbsp;bigger&nbsp;than&nbsp;b"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>   </p>   <p class="para">    Often you&#039;d want to have more than one statement to be executed    conditionally.  Of course, there&#039;s no need to wrap each statement    with an <i>if</i> clause.  Instead, you can group    several statements into a statement group.  For example, this code    would display <span class="computeroutput">a is bigger than b</span>    if <var class="varname">$a</var> is bigger than    <var class="varname">$b</var>, and would then assign the value of    <var class="varname">$a</var> into <var class="varname">$b</var>:    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">$a&nbsp;</span><span style="color: #007700">&gt;&nbsp;</span><span style="color: #0000BB">$b</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"a&nbsp;is&nbsp;bigger&nbsp;than&nbsp;b"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>   </p>   <p class="simpara">    <i>If</i> statements can be nested infinitely within other    <i>if</i> statements, which provides you with complete    flexibility for conditional execution of the various parts of your    program.   </p>  </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.control-structures.html">Control Structures</a></div> <div class="next" style="text-align: right; float: right;"><a href="control-structures.else.html">else</a></div> <div class="up"><a href="language.control-structures.html">Control Structures</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -