<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.get-debug-type.php',
    1 => 'get_debug_type',
    2 => 'Gets the type name of a variable in a way that is suitable for debugging',
  ),
  'up' => 
  array (
    0 => 'ref.var.php',
    1 => 'Variable handling Functions',
  ),
  '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' => 'en',
    '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">Gets the type name of a variable in a way that is suitable for debugging</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">
   Returns the resolved name of the PHP variable <code class="parameter">value</code>.
   This function will resolve objects to their class name, resources to their
   resource type name, and scalar values to their common name as would be used in type
   declarations.
  </p>
  <p class="para">
   This function differs from <span class="function"><a href="function.gettype.php" class="function">gettype()</a></span> in that it returns type names
   that are more consistent with actual usage, rather than those present for historical reasons.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.get-debug-type-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       The variable being type checked.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.get-debug-type-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
     Possible values for the returned <span class="type"><a href="language.types.string.php" class="type string">string</a></span> are:

     <table class="doctable informaltable">
      
       <thead>
        <tr>
         <th>Type + State</th>
         <th>Return Value</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>Booleans (<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>Integers</td>
         <td>
          <code class="literal">&quot;int&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Floats</td>
         <td>
          <code class="literal">&quot;float&quot;</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Strings</td>
         <td>
          <code class="literal">&quot;string&quot;</code>
         </td>
         <td>-</td>
        </tr>

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

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

        <tr>
         <td>Resources (Closed)</td>
         <td>
          <code class="literal">&quot;resource (closed)&quot;</code>
         </td>
         <td>Example: A file stream after being closed with <span class="function"><a href="function.fclose.php" class="function">fclose()</a></span>.</td>
        </tr>

        <tr>
         <td>Objects from Named Classes</td>
         <td>
          The full name of the class including its namespace e.g. <code class="literal">Foo\Bar</code>
         </td>
         <td>-</td>
        </tr>

        <tr>
         <td>Objects from Anonymous Classes</td>
         <td>
          <code class="literal">&quot;class@anonymous&quot;</code> or parent class name/interface name if the class extends another class or implements an interface e.g. <code class="literal">&quot;Foo\Bar@anonymous&quot;</code>
         </td>
         <td>
          Anonymous classes are those created through the <code class="code">$x = new class { ... }</code> syntax
         </td>
        </tr>

       </tbody>
      
     </table>

  </p>
 </div>



 <div class="refsect1 examples" id="refsect1-function.get-debug-type-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>get_debug_type()</strong></span> example</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 />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>The above example will output
something similar to:</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">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.gettype.php" class="function" rel="rdfs-seeAlso">gettype()</a> - Get the type of a variable</span></li>
    <li><span class="function"><a href="function.get-class.php" class="function" rel="rdfs-seeAlso">get_class()</a> - Returns the name of the class of an object</span></li>
   </ul>
  </p>
 </div>

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