Comunitatea PHP Romania
 

 
class_exists

class_exists

(PHP 4 , PHP 5)

class_exists -- Checks if the class has been defined

Description

bool class_exists ( string class_name [, bool autoload])

Notã: 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.

Exemplu 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().

Ultimele discutii in forum RSS Forum

Ultimele articole Ultimele articole

Top membri

Pirahna Pirahna
acasa , in pat
carco carco
Bucuresti
Birkoff Birkoff
Bucuresti
Mascka Mascka
Braila
raul_ raul_
whooper whooper
Toronto ON
mihaitha mihaitha
Sibiu
gabysolomon gabysolomon
Bacau
oriceon oriceon
Constanta
garlicinicolae garlicinicolae

Newsletter


Email:
 inscriere
 renuntare
 
 Arhiva newsletter

Parteneriat

Copyright © 2001-2008 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Loans | Flights | Mortgage | Credit Cards | Adverse Credit Remortgage
Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
Powered by Simplis