PHP - Function class_exists()


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.

Parameters

Sr.No Parameter & Description
1

class_name(Required)

The class name.

2

autoload(Optional)

Whether to call __autoload or not by default.

Return Value

It returns TRUE if class_name is a defined class, FALSE otherwise.

Example

Following is the usage of this function −

<?php
   if (class_exists('HelloWorld')) {
      $helloworld = new HelloWorld();
   }
?> 

php_function_reference.htm

Advertisements