<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.spl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.class-parents.php',
    1 => 'class_parents',
    2 => 'Retourne les classes parentes d\'une classe',
  ),
  'up' => 
  array (
    0 => 'ref.spl.php',
    1 => 'Fonctions SPL',
  ),
  'prev' => 
  array (
    0 => 'function.class-implements.php',
    1 => 'class_implements',
  ),
  'next' => 
  array (
    0 => 'function.class-uses.php',
    1 => 'class_uses',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/spl/functions/class-parents.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.class-parents" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">class_parents</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">class_parents</span> &mdash; <span class="dc-title">
   Retourne les classes parentes d&#039;une classe
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.class-parents-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>class_parents</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.object.php" class="type object">object</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$object_or_class</code></span>, <span class="methodparam"><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span> <code class="parameter">$autoload</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>class_parents()</strong></span> retourne un tableau avec le 
   nom des classes parentes de la classe <code class="parameter">object_or_class</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.class-parents-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">object_or_class</code></dt>
     <dd>
      <p class="para">
       Un objet (instance) ou une chaîne de caractères (nom de la classe).
      </p>
     </dd>
    
    
     <dt><code class="parameter">autoload</code></dt>
     <dd>
      <p class="para">
       Définit s&#039;il faut <a href="language.oop5.autoload.php" class="link">autocharger</a>
       si pas déjà autochargé.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.class-parents-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Un tableau en cas de succès, ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> quand la classe donnée n&#039;existe pas.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.class-parents-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>class_parents()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class </span><span style="color: #0000BB">foo </span><span style="color: #007700">{ }<br />class </span><span style="color: #0000BB">bar </span><span style="color: #007700">extends </span><span style="color: #0000BB">foo </span><span style="color: #007700">{}<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">class_parents</span><span style="color: #007700">(new </span><span style="color: #0000BB">bar</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// vous pouvez aussi spécifier le paramètre comme une chaîne de caractères<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">class_parents</span><span style="color: #007700">(</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">spl_autoload_register</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">// Utilisation de l'autoloading pour charger la classe 'not_loaded'<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">class_parents</span><span style="color: #007700">(</span><span style="color: #DD0000">'not_loaded'</span><span style="color: #007700">, </span><span style="color: #0000BB">true</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="examplescode"><pre class="examplescode">Array
(
   [foo] =&gt; foo
)
Array
(
    [foo] =&gt; foo
)
Array
(
   [parent_de_not_loaded] =&gt; parent_de_not_loaded
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.class-parents-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Il est préférable d&#039;utiliser <a href="language.operators.type.php" class="link"><code class="literal">instanceof</code></a> ou la fonction <span class="function"><a href="function.is-a.php" class="function">is_a()</a></span>
    pour vérifier qu&#039;un objet implémente une interface.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.class-parents-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.class-implements.php" class="function" rel="rdfs-seeAlso">class_implements()</a> - Retourne les interfaces impl&eacute;ment&eacute;es par une classe ou une interface donn&eacute;e</span></li>
    <li><span class="function"><a href="function.is-a.php" class="function" rel="rdfs-seeAlso">is_a()</a> - V&eacute;rifie si l'objet est d'un certain type ou sous-type.</span></li>
    <li><a href="language.operators.type.php" class="link"><code class="literal">instanceof</code></a></li>
   </ul>
  </p>
 </div>

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