<?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.settype.php',
    1 => 'settype',
    2 => 'Legt den Typ einer Variablen fest',
  ),
  'up' => 
  array (
    0 => 'ref.var.php',
    1 => 'Funktionen zur Behandlung von Variablen',
  ),
  'prev' => 
  array (
    0 => 'function.serialize.php',
    1 => 'serialize',
  ),
  'next' => 
  array (
    0 => 'function.strval.php',
    1 => 'strval',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/var/functions/settype.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.settype" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">settype</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">settype</span> &mdash; <span class="dc-title">Legt den Typ einer Variablen fest</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.settype-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>settype</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter reference">&$var</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$type</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Legt den Typ der Variablen <code class="parameter">var</code> als
   <code class="parameter">type</code> fest.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.settype-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">var</code></dt>
     <dd>
      <p class="para">
       Die zu konvertierende Variable.
      </p>
     </dd>
    
    
     <dt><code class="parameter">type</code></dt>
     <dd>
      <p class="para">
       Mögliche Werte für <code class="parameter">type</code> sind:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          &quot;boolean&quot; oder &quot;bool&quot;
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;integer&quot; oder &quot;int&quot;
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;float&quot; oder &quot;double&quot;
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;string&quot;
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;array&quot;
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;object&quot;
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          &quot;null&quot;
         </span>
        </li>
       </ul>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.settype-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt bei Erfolg <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> zurück. Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.settype-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>settype()</strong></span>-Beispiel</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$foo </span><span style="color: #007700">= </span><span style="color: #DD0000">"5bar"</span><span style="color: #007700">; </span><span style="color: #FF8000">// string<br /></span><span style="color: #0000BB">$bar </span><span style="color: #007700">= </span><span style="color: #0000BB">true</span><span style="color: #007700">;   </span><span style="color: #FF8000">// boolean<br /><br /></span><span style="color: #0000BB">settype</span><span style="color: #007700">(</span><span style="color: #0000BB">$foo</span><span style="color: #007700">, </span><span style="color: #DD0000">"integer"</span><span style="color: #007700">); </span><span style="color: #FF8000">// $foo ist jetzt 5   (integer)<br /></span><span style="color: #0000BB">settype</span><span style="color: #007700">(</span><span style="color: #0000BB">$bar</span><span style="color: #007700">, </span><span style="color: #DD0000">"string"</span><span style="color: #007700">);  </span><span style="color: #FF8000">// $bar ist jetzt "1" (string)<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$foo</span><span style="color: #007700">, </span><span style="color: #0000BB">$bar</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 notes" id="refsect1-function.settype-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Der Höchstwert für den Datentyp &quot;int&quot; ist <strong><code><a href="reserved.constants.php#constant.php-int-max">PHP_INT_MAX</a></code></strong>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.settype-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.gettype.php" class="function" rel="rdfs-seeAlso">gettype()</a> - Liefert den Datentyp einer Variablen</span></li>
    <li><a href="language.types.type-juggling.php#language.types.typecasting" class="link">Typ-Umwandlung</a></li>
    <li><a href="language.types.type-juggling.php" class="link">Typen-Tricks</a></li>
   </ul>
  </p>
 </div>


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