<?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.print-r.php',
    1 => 'print_r',
    2 => 'Affiche des informations lisibles pour une variable',
  ),
  'up' => 
  array (
    0 => 'ref.var.php',
    1 => 'Fonctions de gestion des variables',
  ),
  'prev' => 
  array (
    0 => 'function.isset.php',
    1 => 'isset',
  ),
  'next' => 
  array (
    0 => 'function.serialize.php',
    1 => 'serialize',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/var/functions/print-r.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.print-r" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">print_r</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">print_r</span> &mdash; <span class="dc-title">Affiche des informations lisibles pour une variable</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.print-r-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>print_r</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.boolean.php" class="type bool">bool</a></span> <code class="parameter">$return</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>print_r()</strong></span> affiche des informations à propos d&#039;une
   variable, de manière à ce qu&#039;elle soit lisible.
  </p>
  <p class="para">
   <span class="function"><strong>print_r()</strong></span>, <span class="function"><a href="function.var-dump.php" class="function">var_dump()</a></span> et
   <span class="function"><a href="function.var-export.php" class="function">var_export()</a></span> affiche
   également les propriétés protégées et privées d&#039;un objet.
   Les membres des classes statiques ne seront pas affichés.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.print-r-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       L&#039;expression à afficher.
      </p>
     </dd>
    
    
     <dt><code class="parameter">return</code></dt>
     <dd>
      <p class="para">
       Pour obtenir le résultat de <span class="function"><strong>print_r()</strong></span> dans une chaîne,
       utiliser le paramètre <code class="parameter">return</code>. Lorsque ce paramètre vaut
       <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, <span class="function"><strong>print_r()</strong></span> retournera l&#039;information plutôt que de l&#039;afficher.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.print-r-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Si une <a href="language.types.string.php" class="link">chaîne de caractères</a>, un <a href="language.types.integer.php" class="link">entier</a> ou un <a href="language.types.float.php" class="link">nombre décimal</a> est fournie, sa valeur
   sera affichée. Si un <a href="language.types.array.php" class="link">tableau</a> est fourni, les valeurs seront affichées
   dans un format permettant de voir les clés et les éléments. Un format
   similaire sera également utilisé pour les objets.
  </p>
  <p class="para">
   Lorsque le paramètre <code class="parameter">return</code> vaut <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, cette fonction
   retournera une <a href="language.types.string.php" class="link">chaîne de caractères</a>. Autrement, la valeur de retour sera <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
  </p> 
 </div>


 <div class="refsect1 changelog" id="refsect1-function.print-r-changelog">
  <h3 class="title">Historique</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.4.0</td>
       <td>
        Le type de retour est passé de <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span> à <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></span>.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.print-r-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>print_r()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000">&lt;pre&gt;<br /><span style="color: #0000BB">&lt;?php<br />$a </span><span style="color: #007700">= array (</span><span style="color: #DD0000">'a' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'apple'</span><span style="color: #007700">, </span><span style="color: #DD0000">'b' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'banana'</span><span style="color: #007700">, </span><span style="color: #DD0000">'c' </span><span style="color: #007700">=&gt; array (</span><span style="color: #DD0000">'x'</span><span style="color: #007700">, </span><span style="color: #DD0000">'y'</span><span style="color: #007700">, </span><span style="color: #DD0000">'z'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;<br /></span>&lt;/pre&gt;</span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">&lt;pre&gt;
Array
(
    [a] =&gt; apple
    [b] =&gt; banana
    [c] =&gt; Array
        (
            [0] =&gt; x
            [1] =&gt; y
            [2] =&gt; z
        )
)
&lt;/pre&gt;</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Exemple #2 Exemple avec le paramètre <code class="parameter">return</code></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$b </span><span style="color: #007700">= array (</span><span style="color: #DD0000">'m' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'monkey'</span><span style="color: #007700">, </span><span style="color: #DD0000">'foo' </span><span style="color: #007700">=&gt; </span><span style="color: #DD0000">'bar'</span><span style="color: #007700">, </span><span style="color: #DD0000">'x' </span><span style="color: #007700">=&gt; array (</span><span style="color: #DD0000">'x'</span><span style="color: #007700">, </span><span style="color: #DD0000">'y'</span><span style="color: #007700">, </span><span style="color: #DD0000">'z'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$results </span><span style="color: #007700">= </span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$b</span><span style="color: #007700">, </span><span style="color: #0000BB">true</span><span style="color: #007700">); </span><span style="color: #FF8000">// $results contient l'affichage de print_r<br />     <br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$results</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.print-r-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">
 Lorsque le paramètre <code class="parameter">return</code> est utilisé, cette fonction
 utilisait la mise en tampon (buffer) interne de sortie antérieur à PHP 7.1.0, et donc ne peut pas être
 utilisé dans la fonction de rappel de <span class="function"><a href="function.ob-start.php" class="function">ob_start()</a></span>.
</p></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.print-r-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.ob-start.php" class="function" rel="rdfs-seeAlso">ob_start()</a> - Enclenche la temporisation de sortie</span></li>
    <li><span class="function"><a href="function.var-dump.php" class="function" rel="rdfs-seeAlso">var_dump()</a> - Affiche les informations d'une variable</span></li>
    <li><span class="function"><a href="function.var-export.php" class="function" rel="rdfs-seeAlso">var_export()</a> - Retourne le code PHP utilis&eacute; pour g&eacute;n&eacute;rer une variable</span></li>
   </ul>
  </p>
 </div>


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