<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.ctype-alnum.php',
    1 => 'ctype_alnum',
    2 => 'Check for alphanumeric character(s)',
  ),
  'up' => 
  array (
    0 => 'ref.ctype.php',
    1 => 'Ctype Functions',
  ),
  'prev' => 
  array (
    0 => 'ref.ctype.php',
    1 => 'Ctype Functions',
  ),
  'next' => 
  array (
    0 => 'function.ctype-alpha.php',
    1 => 'ctype_alpha',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    '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">Check for alphanumeric character(s)</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ctype-alnum-description">
  <h3 class="title">Description</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">
   Checks if all of the characters in the provided <span class="type"><a href="language.types.string.php" class="type string">string</a></span>,
   <code class="parameter">text</code>, are alphanumeric.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ctype-alnum-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">text</code></dt>
     <dd>
      <p class="para">
       The tested string.
       <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">
If an <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> between -128 and 255 inclusive is provided, it is interpreted as
the ASCII value of a single character (negative values have 256 added in order to allow
characters in the Extended ASCII range). Any other integer is interpreted as a string
containing the decimal digits of the integer.</p></p></blockquote>
       <div class="warning"><strong class="warning">Warning</strong><p class="para">
As of PHP 8.1.0, passing a non-string argument is deprecated.
In the future, the argument will be interpreted as a string instead of an ASCII codepoint.
Depending on the intended behavior, the argument should either be cast to <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
or an explicit call to <span class="function"><a href="function.chr.php" class="function">chr()</a></span> should be made.</p></div>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ctype-alnum-returnvalues"> 
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> if every character in <code class="parameter">text</code> is either
   a letter or a digit, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> otherwise.
   When called with an empty string the result will always be <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">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 A <span class="function"><strong>ctype_alnum()</strong></span> example (using the default locale)</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>The above example will output:</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">See Also</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> - Check for alphabetic character(s)</span></li>
    <li><span class="function"><a href="function.ctype-digit.php" class="function" rel="rdfs-seeAlso">ctype_digit()</a> - Check for numeric character(s)</span></li>
    <li><span class="function"><a href="function.setlocale.php" class="function" rel="rdfs-seeAlso">setlocale()</a> - Set locale information</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); ?>