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

📄 function.empty.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>Determine whether a variable is empty</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="function.doubleval.html">doubleval</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.floatval.html">floatval</a></div> <div class="up"><a href="ref.var.html">Variable handling Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.empty" class="refentry"> <div class="refnamediv">  <h1 class="refname">empty</h1>  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">empty</span> &mdash; <span class="dc-title">Determine whether a variable is empty</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <div class="methodsynopsis dc-description">   <span class="type">bool</span> <span class="methodname"><b><b>empty</b></b></span>    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter">$var</tt></span>   )</div>  <p class="para rdfs-comment">   Determine whether a variable is considered to be empty.  </p> </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">var</tt></i></span>     <dd>      <p class="para">       Variable to be checked      </p>      <blockquote><p><b class="note">Note</b>:                <b>empty()</b> only checks variables as anything else will        result in a parse error. In other words, the following will not work:        <strong class="command">empty(trim($name))</strong>.       <br />      </p></blockquote>      <p class="para">       <b>empty()</b> is the opposite of       <i>(boolean) var</i>,       except that no warning is generated when the variable is not set.      </p>     </dd>    </dt>   </dl>  </p> </div> <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns <b><tt>FALSE</tt></b> if <i><tt class="parameter">var</tt></i> has a non-empty   and non-zero value.  </p>  <p class="para">   The following things are considered to be empty:   <ul class="simplelist">    <li class="member"><i>&quot;&quot; (an empty string)</i></li>    <li class="member"><i>0 (0 as an integer)</i></li>    <li class="member"><i>&quot;0&quot; (0 as a string)</i></li>    <li class="member"><b><tt>NULL</tt></b></li>    <li class="member"><b><tt>FALSE</tt></b></li>    <li class="member"><i>array() (an empty array)</i></li>    <li class="member"><i>var $var; (a variable declared, but without a value in a class)</i></li>   </ul>  </p> </div> <div class="refsect1 changelog">  <h3 class="title">ChangeLog</h3>  <p class="para">   <table class="informaltable">    <colgroup>     <thead valign="middle">      <tr valign="middle">       <th colspan="1">Version</th>       <th colspan="1">Description</th>      </tr>     </thead>     <tbody valign="middle" class="tbody">      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">PHP 5</td>       <td colspan="1" rowspan="1" align="left">        <p class="para">         As of PHP 5, objects with no properties are no longer considered empty.        </p>       </td>      </tr>      <tr valign="middle">       <td colspan="1" rowspan="1" align="left">PHP 4</td>       <td colspan="1" rowspan="1" align="left">        <p class="para">         As of PHP 4, The string value &quot;0&quot; is considered empty.        </p>       </td>      </tr>     </tbody>    </colgroup>   </table>  </p> </div> <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <p class="para">   <div class="example">    <p><b>Example #1      A simple <b>empty()</b> / <a href="function.isset.html" class="function">isset()</a>     comparison.    </b></p>      <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$var&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;Evaluates&nbsp;to&nbsp;true&nbsp;because&nbsp;$var&nbsp;is&nbsp;empty<br /></span><span style="color: #007700">if&nbsp;(empty(</span><span style="color: #0000BB">$var</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'$var&nbsp;is&nbsp;either&nbsp;0,&nbsp;empty,&nbsp;or&nbsp;not&nbsp;set&nbsp;at&nbsp;all'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Evaluates&nbsp;as&nbsp;true&nbsp;because&nbsp;$var&nbsp;is&nbsp;set<br /></span><span style="color: #007700">if&nbsp;(isset(</span><span style="color: #0000BB">$var</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'$var&nbsp;is&nbsp;set&nbsp;even&nbsp;though&nbsp;it&nbsp;is&nbsp;empty'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>    </div>   </div>  </p> </div> <div class="refsect1 notes">  <h3 class="title">Notes</h3>  <blockquote><p><b class="note">Note</b>: <span class="simpara">Because this is a language construct and not a function, it cannot be called using <a href="functions.variable-functions.html" class="link">variable functions</a></span></p></blockquote> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.isset.html" class="function" rel="rdfs-seeAlso">isset()</a></li>    <li class="member"><a href="function.unset.html" class="function" rel="rdfs-seeAlso">unset()</a></li>    <li class="member"><a href="function.array-key-exists.html" class="function" rel="rdfs-seeAlso">array_key_exists()</a></li>    <li class="member"><a href="function.count.html" class="function" rel="rdfs-seeAlso">count()</a></li>     <li class="member"><a href="function.strlen.html" class="function" rel="rdfs-seeAlso">strlen()</a></li>    <li class="member"><a href="types.comparisons.html" class="link">The type comparison tables</a></li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.doubleval.html">doubleval</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.floatval.html">floatval</a></div> <div class="up"><a href="ref.var.html">Variable handling Functions</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 + -