Copyright © tutorialspoint.com

PHP Function class_exists()

previous
Advertisements

Syntax

class_exists ( $class_name [,$autoload] );

Definition and Usage

This function checks if the given class have been defined. Returns TRUE if class_name is a defined class, FALSE otherwise.

Paramters

ParameterDescription
class_nameRequired. The class name.
autoloadOptional. Whether to call __autoload or not by default.

Return Value

Returns TRUE if class_name is a defined class, FALSE otherwise.

Example

Following is the usage of this function:

<?php
if (class_exists('MyClass')) {
    $myclass = new MyClass();
}
?> 
previous

Copyright © tutorialspoint.com