<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.ctype.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.ctype-alnum.php',
    1 => 'ctype_alnum',
    2 => '检测字母数字式字符',
  ),
  'up' => 
  array (
    0 => 'ref.ctype.php',
    1 => 'Ctype 函数',
  ),
  'prev' => 
  array (
    0 => 'ref.ctype.php',
    1 => 'Ctype 函数',
  ),
  'next' => 
  array (
    0 => 'function.ctype-alpha.php',
    1 => 'ctype_alpha',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/ctype/functions/ctype-alnum.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.ctype-alnum" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ctype_alnum</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ctype_alnum</span> &mdash; <span class="dc-title">检测字母数字式字符</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ctype-alnum-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ctype_alnum</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$text</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   检测提供的 <span class="type"><a href="language.types.string.php" class="type string">string</a></span> 类型的 <code class="parameter">text</code> 是否全部为字母数字。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ctype-alnum-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">text</code></dt>
     <dd>
      <p class="para">
       要测试的字符串。
       <blockquote class="note"><p><strong class="note">注意</strong>: <p class="para">
如果给出一个 -128 到 255 之间(含)的<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>, 将会被解释为该值对应的ASCII字符 (负值将加上 256 以支持扩展ASCII字符).
其它整数将会被解释为该值对应的十进制字符串.</p></p></blockquote>
       <div class="warning"><strong class="warning">警告</strong><p class="para">
自 PHP 8.1.0 起，弃用传递非字符串参数。未来该参数将解释为字符串而不是 ASCII 
码点。根据预期行为，应将参数转为字符串或显式调用 <span class="function"><a href="function.chr.php" class="function">chr()</a></span>。</p></div>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ctype-alnum-returnvalues"> 
  <h3 class="title">返回值</h3>
  <p class="para">
   如果 <code class="parameter">text</code> 中所有的字符不是字母就是数字，则返回
   <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>，否则返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。当使用空字符串调用时，结果始终为 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ctype-alnum-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>ctype_alnum()</strong></span> 示例 (使用默认的区域设置)</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$strings </span><span style="color: #007700">= array(</span><span style="color: #DD0000">'AbCd1zyZ9'</span><span style="color: #007700">, </span><span style="color: #DD0000">'foo!#$bar'</span><span style="color: #007700">);<br />foreach (</span><span style="color: #0000BB">$strings </span><span style="color: #007700">as </span><span style="color: #0000BB">$testcase</span><span style="color: #007700">) {<br />    if (</span><span style="color: #0000BB">ctype_alnum</span><span style="color: #007700">(</span><span style="color: #0000BB">$testcase</span><span style="color: #007700">)) {<br />        echo </span><span style="color: #DD0000">"The string </span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000"> consists of all letters or digits.\n"</span><span style="color: #007700">;<br />    } else {<br />        echo </span><span style="color: #DD0000">"The string </span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000"> does not consist of all letters or digits.\n"</span><span style="color: #007700">;<br />    }<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例会输出：</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">The string AbCd1zyZ9 consists of all letters or digits.
The string foo!#$bar does not consist of all letters or digits.</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ctype-alnum-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.ctype-alpha.php" class="function" rel="rdfs-seeAlso">ctype_alpha()</a> - 检测字母字符</span></li>
    <li><span class="function"><a href="function.ctype-digit.php" class="function" rel="rdfs-seeAlso">ctype_digit()</a> - 检测数字字符</span></li>
    <li><span class="function"><a href="function.setlocale.php" class="function" rel="rdfs-seeAlso">setlocale()</a> - 设置区域信息</span></li>
    <li><span class="function"><a href="intlchar.isalnum.php" class="function" rel="rdfs-seeAlso">IntlChar::isalnum()</a> - Check if code point is an alphanumeric character</span></li>
   </ul>
  </p>
 </div>

</div><?php manual_footer($setup); ?>