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

📄 language.operators.comparison.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Comparison Operators</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.operators.bitwise.html">Bitwise Operators</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.operators.errorcontrol.html">Error Control Operators</a></div> <div class="up"><a href="language.operators.html">Operators</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="language.operators.comparison" class="sect1">   <h2 class="title">Comparison Operators</h2>   <p class="simpara">    Comparison operators, as their name implies, allow you to compare    two values.  You may also be interested in viewing    <a href="types.comparisons.html" class="link">the type comparison tables</a>,     as they show examples of various type related comparisons.   </p>   <table border="5">    <caption><b>Comparison Operators</b></caption>    <colgroup>     <thead valign="middle">      <tr valign="middle">       <th colspan="1">Example</th>       <th colspan="1">Name</th>       <th colspan="1">Result</th>      </tr>     </thead>     <tbody valign="middle" class="tbody">      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a == $b</td>       <td colspan="1" rowspan="1" align="left">Equal</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is equal to $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a === $b</td>       <td colspan="1" rowspan="1" align="left">Identical</td>       <td colspan="1" rowspan="1" align="left">        <b><tt>TRUE</tt></b> if $a is equal to $b, and they are of the same        type. (introduced in PHP 4)       </td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a != $b</td>       <td colspan="1" rowspan="1" align="left">Not equal</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is not equal to $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a &lt;&gt; $b</td>       <td colspan="1" rowspan="1" align="left">Not equal</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is not equal to $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a !== $b</td>       <td colspan="1" rowspan="1" align="left">Not identical</td>       <td colspan="1" rowspan="1" align="left">        <b><tt>TRUE</tt></b> if $a is not equal to $b, or they are not of the same        type. (introduced in PHP 4)       </td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a &lt; $b</td>       <td colspan="1" rowspan="1" align="left">Less than</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is strictly less than $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a &gt; $b</td>       <td colspan="1" rowspan="1" align="left">Greater than</td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is strictly greater than $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a &lt;= $b</td>       <td colspan="1" rowspan="1" align="left">Less than or equal to </td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is less than or equal to $b.</td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">$a &gt;= $b</td>       <td colspan="1" rowspan="1" align="left">Greater than or equal to </td>       <td colspan="1" rowspan="1" align="left"><b><tt>TRUE</tt></b> if $a is greater than or equal to $b.</td>      </tr>     </tbody>    </colgroup>   </table>   <p class="para">    If you compare an integer with a string, the string is    <a href="language.types.string.html#language.types.string.conversion" class="link">converted to a number</a>.    If you compare two numerical strings, they are compared as integers. These    rules also apply to the    <a href="control-structures.switch.html" class="link">switch</a> statement.    <div class="informalexample">     <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">0&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"a"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;0&nbsp;==&nbsp;0&nbsp;-&gt;&nbsp;true<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #DD0000">"1"&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"01"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;1&nbsp;==&nbsp;1&nbsp;-&gt;&nbsp;true<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #DD0000">"1"&nbsp;</span><span style="color: #007700">==&nbsp;</span><span style="color: #DD0000">"1e0"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;1&nbsp;==&nbsp;1&nbsp;-&gt;&nbsp;true<br /><br /></span><span style="color: #007700">switch&nbsp;(</span><span style="color: #DD0000">"a"</span><span style="color: #007700">)&nbsp;{<br />case&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">:<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"0"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br />case&nbsp;</span><span style="color: #DD0000">"a"</span><span style="color: #007700">:&nbsp;</span><span style="color: #FF8000">//&nbsp;never&nbsp;reached&nbsp;because&nbsp;"a"&nbsp;is&nbsp;already&nbsp;matched&nbsp;with&nbsp;0<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"a"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;break;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>     </div>    </div>    </p>   <p class="para">    For various types, comparison is done according to the following    table (in order).   </p>   <table border="5">    <caption><b>Comparison with Various Types</b></caption>    <colgroup>     <thead valign="middle">      <tr valign="middle">       <th colspan="1">Type of Operand 1</th>       <th colspan="1">Type of Operand 2</th>       <th colspan="1">Result</th>      </tr>     </thead>

⌨️ 快捷键说明

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