<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.ctype-digit.php',
    1 => 'ctype_digit',
    2 => 'Pr&uuml;ft auf Ziffern',
  ),
  'up' => 
  array (
    0 => 'ref.ctype.php',
    1 => 'Ctype Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.ctype-cntrl.php',
    1 => 'ctype_cntrl',
  ),
  'next' => 
  array (
    0 => 'function.ctype-graph.php',
    1 => 'ctype_graph',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/ctype/functions/ctype-digit.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.ctype-digit" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ctype_digit</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ctype_digit</span> &mdash; <span class="dc-title">Prüft auf Ziffern</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ctype-digit-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ctype_digit</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">
   Prüft, ob der übergebene <code class="parameter">text</code> nur aus Ziffern
   besteht.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ctype-digit-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">text</code></dt>
     <dd>
      <p class="para">
       Der zu prüfende String.
       <blockquote class="note"><p><strong class="note">Hinweis</strong>: <p class="para">
Wenn ein <span class="type"><a href="language.types.integer.php" class="type int">int</a></span> zwischen -128 und 255 (inklusive) übergeben wird, wird dieser als
ASCII-Wert eines einzelnen Buchstabens interpretiert (zu negativen Werten wird 256 dazu addiert,
um Buchstaben des erweiterten ASCII-Zeichensatzes zu erlauben). Alle anderen Integer werden wie
eine Zeichenkette interpretiert, welche die dezimalen Ziffern des Integers enthält.</p></p></blockquote>
       <div class="warning"><strong class="warning">Warnung</strong><p class="para">
Seit PHP 8.1.0 ist die Übergabe eines Nicht-String-Arguments veraltet. In
Zukunft wird das Argument statt als ASCII-Codepunkt als String interpretiert
werden. Je nach beabsichtigtem Verhalten sollte das Argument entweder in <a href="language.types.string.php" class="link">String</a>
umgewandelt werden, oder es sollte ein expliziter Aufruf von
<span class="function"><a href="function.chr.php" class="function">chr()</a></span> erfolgen.</p></div>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ctype-digit-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück, wenn jedes Zeichen in <code class="parameter">text</code>
   eine Ziffer ist, ansonsten <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
   Bei einem Aufruf mit einer leeren Zeichenkette wird immer <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ctype-digit-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>ctype_digit()</strong></span>-Beispiel</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">'1820.20'</span><span style="color: #007700">, </span><span style="color: #DD0000">'10002'</span><span style="color: #007700">, </span><span style="color: #DD0000">'wsl!12'</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_digit</span><span style="color: #007700">(</span><span style="color: #0000BB">$testcase</span><span style="color: #007700">)) {<br />        echo </span><span style="color: #DD0000">"Der String </span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000"> besteht aus Ziffern.\n"</span><span style="color: #007700">;<br />    } else {<br />        echo </span><span style="color: #DD0000">"Der String </span><span style="color: #0000BB">$testcase</span><span style="color: #DD0000"> enthält nicht nur Ziffern.\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>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Der String 1820.20 enthält nicht nur Ziffern.
Der String 10002 besteht aus Ziffern.
Der String wsl!12 enthält nicht nur Ziffern.</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 <span class="function"><strong>ctype_digit()</strong></span>-Beispiel für den Vergleich von Strings mit ganzen Zahlen</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$numeric_string </span><span style="color: #007700">= </span><span style="color: #DD0000">'42'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$integer        </span><span style="color: #007700">= </span><span style="color: #0000BB">42</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">ctype_digit</span><span style="color: #007700">(</span><span style="color: #0000BB">$numeric_string</span><span style="color: #007700">);  </span><span style="color: #FF8000">// true<br /></span><span style="color: #0000BB">ctype_digit</span><span style="color: #007700">(</span><span style="color: #0000BB">$integer</span><span style="color: #007700">);         </span><span style="color: #FF8000">// false (ASCII 42 ist das Zeichen *)<br /><br /></span><span style="color: #0000BB">is_numeric</span><span style="color: #007700">(</span><span style="color: #0000BB">$numeric_string</span><span style="color: #007700">);   </span><span style="color: #FF8000">// true<br /></span><span style="color: #0000BB">is_numeric</span><span style="color: #007700">(</span><span style="color: #0000BB">$integer</span><span style="color: #007700">);          </span><span style="color: #FF8000">// true<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ctype-digit-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.ctype-alnum.php" class="function" rel="rdfs-seeAlso">ctype_alnum()</a> - Pr&uuml;ft auf alphanumerische Zeichen</span></li>
    <li><span class="function"><a href="function.ctype-xdigit.php" class="function" rel="rdfs-seeAlso">ctype_xdigit()</a> - Pr&uuml;ft auf Zeichen, die eine Hexadezimalziffer darstellen</span></li>
    <li><span class="function"><a href="function.is-numeric.php" class="function" rel="rdfs-seeAlso">is_numeric()</a> - Pr&uuml;ft, ob eine Variable eine Zahl oder ein numerischer String ist</span></li>
    <li><span class="function"><a href="function.is-int.php" class="function" rel="rdfs-seeAlso">is_int()</a> - Pr&uuml;ft, ob eine Variable vom Typ int ist</span></li>
    <li><span class="function"><a href="function.is-string.php" class="function" rel="rdfs-seeAlso">is_string()</a> - Pr&uuml;ft, ob Variable vom Typ string ist</span></li>
    <li><span class="function"><a href="intlchar.isdigit.php" class="function" rel="rdfs-seeAlso">IntlChar::isdigit()</a> - Check if code point is a digit character</span></li>
   </ul>
  </p>
 </div>


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