<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.get-debug-type.php',
    1 => 'get_debug_type',
    2 => 'Renvoie le nom du type de la variable d\'une mani&egrave;re adapt&eacute;e au d&eacute;bogage',
  ),
  'up' => 
  array (
    0 => 'ref.var.php',
    1 => 'Fonctions de gestion des variables',
  ),
  'prev' => 
  array (
    0 => 'function.floatval.php',
    1 => 'floatval',
  ),
  'next' => 
  array (
    0 => 'function.get-defined-vars.php',
    1 => 'get_defined_vars',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/var/functions/get-debug-type.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.get-debug-type" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">get_debug_type</h1>
  <p class="verinfo">(PHP 8)</p><p class="refpurpose"><span class="refname">get_debug_type</span> &mdash; <span class="dc-title">Renvoie le nom du type de la variable d&#039;une manière adaptée au débogage</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.get-debug-type-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>get_debug_type</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.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   Renvoie le nom résolu de la variable PHP <code class="parameter">value</code>.
   Cette fonction résoudra les objets à leur nom de classe, les ressources à leur
   nom de type de ressource, et les valeurs scalaires à leur nom commun tel qu&#039;il serait utilisé dans les déclarations
   de type.
  </p>
  <p class="para">
   Cette fonction diffère de <span class="function"><a href="function.gettype.php" class="function">gettype()</a></span> en ce qu&#039;elle renvoie des noms de type
   qui sont plus cohérents avec l&#039;utilisation réelle, plutôt que ceux présents pour des raisons historiques.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.get-debug-type-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       La variable dont le type doit être vérifié.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.get-debug-type-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
     Les types possibles de retour <a href="language.types.string.php" class="link">chaîne de caractères</a> sont :

     <table class="doctable informaltable">
      
       <thead>
        <tr>
         <th>Type + État</th>
         <th>Valeur de retour</th>
         <th>Notes</th>
        </tr>

       </thead>

       <tbody class="tbody">
        <tr>
         <td>null</td>
         <td>
          <code class="literal">&quot;null&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Booléens (<strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>)</td>
         <td>
          <code class="literal">&quot;bool&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Nombres entiers</td>
         <td>
          <code class="literal">&quot;int&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Nombres à virgules flottantes</td>
         <td>
          <code class="literal">&quot;float&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Chaines de caractères</td>
         <td>
          <code class="literal">&quot;string&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Tableaux</td>
         <td>
          <code class="literal">&quot;array&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Ressources</td>
         <td>
          <code class="literal">&quot;resource (resourcename)&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Ressources (Closed)</td>
         <td>
          <code class="literal">&quot;resource (closed)&quot;</code>
         </td>
         <td>Exemple: Un stream de fichier après être fermé avec <span class="function"><a href="function.fclose.php" class="function">fclose()</a></span>.</td>
        </tr>

        <tr>
         <td>Objets depuis des Classes Nommées</td>
         <td>
          Le nom complet de la classe incluant le namespace par exemple <code class="literal">Foo\Bar</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Objets depuis des Classes Anonymes</td>
         <td>
          <code class="literal">&quot;class@anonymous&quot;</code> ou le nom de la classe parente/le nom de l&#039;interface si la classe étend une autre classe ou
          implémente une interface, par exemple <code class="literal">&quot;Foo\Bar@anonymous&quot;</code>
         </td>
         <td>
          Les classes anonymes sont créer via la syntaxe <code class="code">$x = new class { ... }</code>
         </td>
        </tr>

       </tbody>
      
     </table>

  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-function.get-debug-type-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple de <span class="function"><strong>get_debug_type()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">namespace </span><span style="color: #0000BB">Foo</span><span style="color: #007700">;<br /><br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(</span><span style="color: #0000BB">null</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">get_debug_type</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">;<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(</span><span style="color: #0000BB">1</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(</span><span style="color: #0000BB">0.1</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(</span><span style="color: #DD0000">"foo"</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">([]), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'/examples/book.xml'</span><span style="color: #007700">, </span><span style="color: #DD0000">'rb'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(new </span><span style="color: #0000BB">stdClass</span><span style="color: #007700">), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(new class {}), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /><br />interface </span><span style="color: #0000BB">A </span><span style="color: #007700">{}<br />interface </span><span style="color: #0000BB">B </span><span style="color: #007700">{}<br />class </span><span style="color: #0000BB">C </span><span style="color: #007700">{}<br /><br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(new class implements </span><span style="color: #0000BB">A </span><span style="color: #007700">{}), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(new class implements </span><span style="color: #0000BB">A</span><span style="color: #007700">,</span><span style="color: #0000BB">B </span><span style="color: #007700">{}), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(new class extends </span><span style="color: #0000BB">C </span><span style="color: #007700">{}), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">get_debug_type</span><span style="color: #007700">(new class extends </span><span style="color: #0000BB">C </span><span style="color: #007700">implements </span><span style="color: #0000BB">A </span><span style="color: #007700">{}), </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Résultat de l&#039;exemple ci-dessus est similaire à :</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">null
bool
int
float
string
array
resource (stream)
resource (closed)
stdClass
class@anonymous
Foo\A@anonymous
Foo\A@anonymous
Foo\C@anonymous
Foo\C@anonymous</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.get-debug-type-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.gettype.php" class="function" rel="rdfs-seeAlso">gettype()</a> - Retourne le type de la variable</span></li>
    <li><span class="function"><a href="function.get-class.php" class="function" rel="rdfs-seeAlso">get_class()</a> - Retourne le nom de la classe d'un objet</span></li>
   </ul>
  </p>
 </div>

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