This function Checks if the class has been defined.

Syntax: class_exists ( string class_name , bool autoload )

Description:

This function returns TRUE if the class_name has been defined, FALSE otherwise.It 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.

Example:
Code:

 
class myclass
{
var $name;
function set_name($name)
{
$this->name=$name;
}

function get_name()
{
echo $this->name;
}

}
if(class_exists('myclass'))
{
$obj=new myclass;
$obj->set_name('sadique');
$obj->get_name();
}
else
{
echo "myclass class is not exist.";
}

Output:

Swan

eXTReMe Tracker