<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.classobj.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.class-exists.php',
    1 => 'class_exists',
    2 => 'Verifica se la classe &egrave; stata definita',
  ),
  'up' => 
  array (
    0 => 'ref.classobj.php',
    1 => 'Classes/Object Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.class-alias.php',
    1 => 'class_alias',
  ),
  'next' => 
  array (
    0 => 'function.enum-exists.php',
    1 => 'enum_exists',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/classobj/functions/class-exists.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.class-exists" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">class_exists</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">class_exists</span> &mdash; <span class="dc-title">Verifica se la classe è stata definita</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.class-exists-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>class_exists</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$class_name</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"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Questa funzione verifica se la classe è stata definita o meno.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.class-exists-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">class_name</code></dt>
     <dd>
      <p class="para">
       Il nome della classe. Il nome è cercato in modo case-insensitive.
      </p>
     </dd>
    
    
     <dt><code class="parameter">autoload</code></dt>
     <dd>
      <p class="para">
       Se chiamare o no <a href="language.oop5.autoload.php" class="link">__autoload</a> per default.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.class-exists-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Restituisce <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> se <code class="parameter">class_name</code> è una classe definita,
   <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso contrario.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.class-exists-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 Esempio di <span class="function"><strong>class_exists()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Verifica che la classe esista prima di provare ad usarla<br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">class_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'MyClass'</span><span style="color: #007700">)) {<br />    </span><span style="color: #0000BB">$myclass </span><span style="color: #007700">= new </span><span style="color: #0000BB">MyClass</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
   <div class="example" id="example-2">
    <p><strong>Example #2 Esempio del parametro <code class="parameter">autoload</code></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">__autoload</span><span style="color: #007700">(</span><span style="color: #0000BB">$class</span><span style="color: #007700">)<br />{<br />    include(</span><span style="color: #0000BB">$class </span><span style="color: #007700">. </span><span style="color: #DD0000">'.php'</span><span style="color: #007700">);<br /><br />    </span><span style="color: #FF8000">// Verifica per vedere se l'include ha dichiarato la classe<br />    </span><span style="color: #007700">if (!</span><span style="color: #0000BB">class_exists</span><span style="color: #007700">(</span><span style="color: #0000BB">$class</span><span style="color: #007700">, </span><span style="color: #0000BB">false</span><span style="color: #007700">)) {<br />        </span><span style="color: #0000BB">trigger_error</span><span style="color: #007700">(</span><span style="color: #DD0000">"Unable to load class: </span><span style="color: #0000BB">$class</span><span style="color: #DD0000">"</span><span style="color: #007700">, </span><span style="color: #0000BB">E_USER_WARNING</span><span style="color: #007700">);<br />    }<br />}<br /><br />if (</span><span style="color: #0000BB">class_exists</span><span style="color: #007700">(</span><span style="color: #DD0000">'MyClass'</span><span style="color: #007700">)) {<br />    </span><span style="color: #0000BB">$myclass </span><span style="color: #007700">= new </span><span style="color: #0000BB">MyClass</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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

 <div class="refsect1 seealso" id="refsect1-function.class-exists-seealso">
  <h3 class="title">Vedere anche:</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.function-exists.php" class="function" rel="rdfs-seeAlso">function_exists()</a> - Return true if the given function has been defined</span></li>
    <li><span class="function"><a href="function.interface-exists.php" class="function" rel="rdfs-seeAlso">interface_exists()</a> - Checks if the interface has been defined</span></li>
    <li><span class="function"><a href="function.get-declared-classes.php" class="function" rel="rdfs-seeAlso">get_declared_classes()</a> - Restituisce un array con i nomi delle classi definite</span></li>
   </ul>
  </p>
 </div>

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