<?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.intval.php',
    1 => 'intval',
    2 => 'Konvertiert einen Wert nach integer',
  ),
  'up' => 
  array (
    0 => 'ref.var.php',
    1 => 'Funktionen zur Behandlung von Variablen',
  ),
  'prev' => 
  array (
    0 => 'function.gettype.php',
    1 => 'gettype',
  ),
  'next' => 
  array (
    0 => 'function.is-array.php',
    1 => 'is_array',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/var/functions/intval.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.intval" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">intval</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">intval</span> &mdash; <span class="dc-title">Konvertiert einen Wert nach integer</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.intval-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>intval</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="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$base</code><span class="initializer"> = 10</span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Gibt den <span class="type"><a href="language.types.integer.php" class="type integer">integer</a></span>-Wert von <code class="parameter">value</code> unter
   Verwendung der angegebenen Basis (Standardwert ist
   <code class="parameter">base</code>=10). <span class="function"><strong>intval()</strong></span> sollte nicht
   auf Objekte angewandt werden, da dies eine Meldung vom Typ
   <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> erzeugt und den Wert 1 zurückgibt.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.intval-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       Der skalare Wert (das kann ein Ausdruck oder eine einfache Variable
       sein, nicht jedoch ein Array oder Objekt.), der nach
       <span class="type"><a href="language.types.integer.php" class="type integer">integer</a></span> konvertiert werden soll.
      </p>
     </dd>
    
    
     <dt><code class="parameter">base</code></dt>
     <dd>
      <p class="para">
       Die Basis der Konvertierung
      </p>
      <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
       <p class="para">
        Wenn <code class="parameter">base</code> 0 ist, wird die verwendete Basis
        durch das Format von <code class="parameter">value</code> bestimmt:
        <ul class="itemizedlist">
         <li class="listitem">
          <span class="simpara">
           wenn die Zeichenkette ein Präfix &quot;0x&quot; (oder &quot;0X&quot;) enthält, ist die
           Basis 16 (hexadezimal); andernfalls,
          </span>
         </li>
         <li class="listitem">
          <span class="simpara">
           wenn die Zeichenkette mit &quot;0b&quot; (oder &quot;0B&quot;) beginnt, ist die Basis 2
           (binär); andernfalls,
          </span>
         </li>
         <li class="listitem">
          <span class="simpara">
           wenn die Zeichenkette mit &quot;0&quot; beginnt, ist die Basis 8 (oktal);
           andernfalls,
          </span>
         </li>
         <li class="listitem">
          <span class="simpara">
           ist die Basis 10 (dezimal).
          </span>
         </li>
        </ul>
       </p>
      </p></blockquote>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.intval-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Der integer-Wert von <code class="parameter">value</code> bei Erfolg, sonst 0.
   Leere Arrays geben den Wert 0 zurück, nichtleere Arrays den Wert 1.
  </p>
  <p class="para">
   Der Maximalwert hängt vom System ab. 32-Bit-Systeme haben einen maximalen
   Wertebereich für signed integer von -2147483648 bis 2147483647. Also wird
   beispielsweise auf solch einem System
   <code class="literal">intval(&#039;1000000000000&#039;)</code> 2147483647 zurückgeben. Der
   maximale signed integer-Wert auf 64-Bit-Systemen ist 9223372036854775807.
  </p>
  <p class="para">
   Zeichenketten werden meistens 0 zurückgeben, auch wenn das erste Zeichen
   hier entscheidend ist. Es gelten die normalen Regeln zur <a href="language.types.integer.php#language.types.integer.casting" class="link">Umwandlung nach integer</a>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.intval-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>
       Die Fehlerstufe bei der Konvertierung eines Objekts wurde von
       <strong><code><a href="errorfunc.constants.php#constant.e-notice">E_NOTICE</a></code></strong> auf <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>
       geändert.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.intval-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>intval()</strong></span>-Beispiele</strong></p>
    <div class="example-contents"><p>
     Die folgenden Beispiele beziehen sich auf ein 64-Bit-System
    </p></div>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">42</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                      </span><span style="color: #FF8000">// 42<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">4.7</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                     </span><span style="color: #FF8000">// 4<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'42'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                    </span><span style="color: #FF8000">// 42<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'+42'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                   </span><span style="color: #FF8000">// 42<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'-42'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                   </span><span style="color: #FF8000">// -42<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">042</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                     </span><span style="color: #FF8000">// 34<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'042'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                   </span><span style="color: #FF8000">// 42<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">1e10</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                    </span><span style="color: #FF8000">// 10000000000<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'1e10'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                  </span><span style="color: #FF8000">// 10000000000<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">0x1A</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                    </span><span style="color: #FF8000">// 26<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'0x1A'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                  </span><span style="color: #FF8000">// 0<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'0x1A'</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;               </span><span style="color: #FF8000">// 26<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">42000000</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                </span><span style="color: #FF8000">// 42000000<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">420000000000000000000</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;   </span><span style="color: #FF8000">// -4275113695319687168<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'420000000000000000000'</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// 9223372036854775807<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">42</span><span style="color: #007700">, </span><span style="color: #0000BB">8</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                   </span><span style="color: #FF8000">// 42<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #DD0000">'42'</span><span style="color: #007700">, </span><span style="color: #0000BB">8</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                 </span><span style="color: #FF8000">// 34<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(array()), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                 </span><span style="color: #FF8000">// 0<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">, </span><span style="color: #DD0000">'bar'</span><span style="color: #007700">)), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;     </span><span style="color: #FF8000">// 1<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">false</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                   </span><span style="color: #FF8000">// 0<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">intval</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;                    </span><span style="color: #FF8000">// 1<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.intval-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Der Parameter <code class="parameter">base</code> hat keinerlei Auswirkung, wenn
    der Parameter <code class="parameter">value</code> keine Zeichenkette ist.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.intval-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.boolval.php" class="function" rel="rdfs-seeAlso">boolval()</a> - Get the boolean value of a variable</span></li>
    <li><span class="function"><a href="function.floatval.php" class="function" rel="rdfs-seeAlso">floatval()</a> - Konvertiert einen Wert nach float</span></li>
    <li><span class="function"><a href="function.strval.php" class="function" rel="rdfs-seeAlso">strval()</a> - Ermittelt die String-Repr&auml;sentation einer Variable</span></li>
    <li><span class="function"><a href="function.settype.php" class="function" rel="rdfs-seeAlso">settype()</a> - Legt den Typ einer Variablen fest</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><a href="language.types.type-juggling.php" class="link">Typen-Tricks</a></li>
    <li><a href="ref.bc.php" class="link">BCMath - Mathematische Funktionen mit beliebiger Genauigkeit</a></li>
   </ul>
  </p>
 </div>


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