Home Menu

class_exists

Checks if the class has been defined

Syntax

class_exists ( string $class_name [, bool $autoload = TRUE ] ) : bool

Parameters

class_name

The class name. The name is matched in a case-insensitive manner.

autoload

Whether or not to call __autoload by default.

Return

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

Examples

class_name

<?

class myclass
{
}

$class_name = "myclass";

$return = class_exists($class_name);

var_export($return);

?>
true

autoload

<?

class myclass
{
}

$class_name = "myclass";
$autoload = false;

$return = class_exists($class_name, $autoload);

var_export($return);

?>
true

1

<?

class myclass
{
}

$class_name = "myclass";

$return = class_exists($class_name);

if ($return)
{
    $myobject = new myclass;

    var_export($myobject);
}

?>
myclass::__set_state(array(
))

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms