<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.var.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.is-numeric.php',
    1 => 'is_numeric',
    2 => 'Pr&uuml;ft, ob eine Variable eine Zahl oder ein numerischer String ist',
  ),
  'up' => 
  array (
    0 => 'ref.var.php',
    1 => 'Funktionen zur Behandlung von Variablen',
  ),
  'prev' => 
  array (
    0 => 'function.is-null.php',
    1 => 'is_null',
  ),
  'next' => 
  array (
    0 => 'function.is-object.php',
    1 => 'is_object',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/var/functions/is-numeric.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.is-numeric" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">is_numeric</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">is_numeric</span> &mdash; <span class="dc-title">
   Prüft, ob eine Variable eine Zahl oder ein numerischer String ist
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.is-numeric-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>is_numeric</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</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 die gegebene Variable eine Zahl oder ein
   <a href="language.types.numeric-strings.php" class="link">numerischer String</a>
   ist.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.is-numeric-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       Die zu untersuchende Variable
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.is-numeric-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 <code class="parameter">value</code> eine Zahl oder ein
   <a href="language.types.numeric-strings.php" class="link">numerischer String</a>
   ist, ansonsten <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.is-numeric-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       Numerische Strings, die mit einem Leerzeichen enden
       (<code class="literal">&quot;42 &quot;</code>), geben nun <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück. Zuvor wurde
       stattdessen <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.is-numeric-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>is_numeric()</strong></span>-Beispiele</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$tests </span><span style="color: #007700">= array(<br />    </span><span style="color: #DD0000">"42"</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">1337</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">0x539</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">02471</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">0b10100111001</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">1337e0</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"0x539"</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"02471"</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"0b10100111001"</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"1337e0"</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"nicht numerisch"</span><span style="color: #007700">,<br />    array(),<br />    </span><span style="color: #0000BB">9.1</span><span style="color: #007700">,<br />    </span><span style="color: #0000BB">null</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">''</span><span style="color: #007700">,<br />);<br /><br />foreach (</span><span style="color: #0000BB">$tests </span><span style="color: #007700">as </span><span style="color: #0000BB">$element</span><span style="color: #007700">) {<br />    if (</span><span style="color: #0000BB">is_numeric</span><span style="color: #007700">(</span><span style="color: #0000BB">$element</span><span style="color: #007700">)) {<br />        echo </span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$element</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">) . </span><span style="color: #DD0000">" ist numerisch"</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />    } else {<br />        echo </span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$element</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">) . </span><span style="color: #DD0000">" ist NICHT numerisch"</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</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="annotation-interactive examplescode"><pre class="examplescode">&#039;42&#039; ist numerisch
1337 ist numerisch
1337 ist numerisch
1337 ist numerisch
1337 ist numerisch
1337.0 ist numerisch
&#039;0x539&#039; ist NICHT numerisch
&#039;02471&#039; ist numerisch
&#039;0b10100111001&#039; ist NICHT numerisch
&#039;1337e0&#039; ist numerisch
&#039;nicht numerisch&#039; ist NICHT numerisch
array (
) ist NICHT numerisch
9.1 ist numerisch
NULL ist NICHT numerisch
&#039;&#039; ist NICHT numerisch</pre>
</div>
    </div>
   </div>
  </p>

  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 <span class="function"><strong>is_numeric()</strong></span> mit Leerzeichen</strong></p>
    <div class="example-contents">
     <div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$tests </span><span style="color: #007700">= [<br />    </span><span style="color: #DD0000">" 42"</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"42 "</span><span style="color: #007700">,<br />    </span><span style="color: #DD0000">"\u{A0}9001"</span><span style="color: #007700">, </span><span style="color: #FF8000">// nicht umbrechendes Leerzeichen<br />    </span><span style="color: #DD0000">"9001\u{A0}"</span><span style="color: #007700">, </span><span style="color: #FF8000">// nicht umbrechendes Leerzeichen<br /></span><span style="color: #007700">];<br /><br />foreach (</span><span style="color: #0000BB">$tests </span><span style="color: #007700">as </span><span style="color: #0000BB">$element</span><span style="color: #007700">) {<br />    if (</span><span style="color: #0000BB">is_numeric</span><span style="color: #007700">(</span><span style="color: #0000BB">$element</span><span style="color: #007700">)) {<br />        echo </span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$element</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">) . </span><span style="color: #DD0000">" ist numerisch"</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />    } else {<br />        echo </span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$element</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">) . </span><span style="color: #DD0000">" ist NICHT numerisch"</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</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 mit PHP 8 folgende Ausgabe:</p></div>
    <div class="example-contents screen">
     <div class="annotation-interactive examplescode"><pre class="examplescode">&#039; 42&#039; ist numerisch
&#039;42 &#039; ist numerisch
&#039; 9001&#039; ist NICHT numerisch
&#039;9001 &#039; ist NICHT numerisch</pre>
</div>
    </div>
    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt mit PHP 7 folgende Ausgabe:</p></div>
    <div class="example-contents screen">
     <div class="annotation-interactive examplescode"><pre class="examplescode">&#039; 42&#039; ist numerisch
&#039;42 &#039; ist NICHT numerisch
&#039; 9001&#039; ist NICHT numerisch
&#039;9001 &#039; ist NICHT numerisch</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.is-numeric-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="language.types.numeric-strings.php" class="link">Numerische Strings</a></li>
    <li><span class="function"><a href="function.ctype-digit.php" class="function" rel="rdfs-seeAlso">ctype_digit()</a> - Pr&uuml;ft auf Ziffern</span></li>
    <li><span class="function"><a href="function.is-bool.php" class="function" rel="rdfs-seeAlso">is_bool()</a> - Pr&uuml;ft, ob eine Variable vom Typ boolean ist</span></li>
    <li><span class="function"><a href="function.is-null.php" class="function" rel="rdfs-seeAlso">is_null()</a> - Pr&uuml;ft, ob eine Variable null enth&auml;lt</span></li>
    <li><span class="function"><a href="function.is-float.php" class="function" rel="rdfs-seeAlso">is_float()</a> - Pr&uuml;ft, ob eine Variable vom Typ float 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="function.is-object.php" class="function" rel="rdfs-seeAlso">is_object()</a> - Pr&uuml;ft, ob eine Variable vom Typ object ist</span></li>
    <li><span class="function"><a href="function.is-array.php" class="function" rel="rdfs-seeAlso">is_array()</a> - Pr&uuml;ft, ob die Variable ein Array ist</span></li>
    <li><span class="function"><a href="function.filter-var.php" class="function" rel="rdfs-seeAlso">filter_var()</a> - Filtert eine Variable mit einem angegebenen Filter</span></li>
   </ul>
  </p>
 </div>


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