Home :: International :: Manuals :: Howto :: FAQ :: Man Pages :: Email Login

 
 

 

class_exists

(PHP 4 , PHP 5)

class_exists -- Checks if the class has been defined

Description

bool class_exists ( string class_name [, bool autoload])

Bemærk: The autoload parameter was added in PHP 5

This function returns TRUE if the class given by class_name has been defined, FALSE otherwise.

class_exists() will attempt to call __autoload by default, if you don't want class_exists() to call __autoload(), you can set the parameter autoload to FALSE.

Eksempel 1. autoload parameter example

<?php
    
function __autoload($class) {
        include(
$class . '.php');

        
/* Check to see it the include defined the class */
        
if ( !class_exists($class, false) ) {
           
trigger_error("Unable to load class $class", E_USER_ERROR);
        }
    }
    
    if(
class_exists('MyClass') ) {
        
$myclass = new MyClass();
    }

?>

See also get_declared_classes().

 
 
 
 
Google
  Web Linuxinfor   
 

Home :: Copyright :: Privacy :: Credits :: Get a free Linuxinfor Email Account

Document on this page is part of "PHP Manualen". See Index Page for more info about Authorship and Copyright.

1999-2009 Linuxinfor.com. No rights reserved.