1. get_class: By using this, we can get the class name of an object.
<?php
class cls1
{
}
$obj=new cls1();
echo get_class($obj);
?>Output:
2. get_class_vars: It is used to get all variables of a class as Array elements.
<?php
class cls1
{
var $x=100;
var $y=200;
}
print_r(get_class_vars("cls1"));
?>Output:
3. get_class_methods: To get the all methods of a class as an array.
<?php
class cls1
{
function fun1()
{
}
function fun2()
{
}
}
print_r(get_class_methods("cls1"));
?>Output:
4. get_declare_classes: To get the all declare classes in current script along with predefined classes.
<?php
class cls1
{
}
print_r(get_declared_classes());
?>Output:
5. get_object_vars: To get all variables of an object as an array.
<?php
class cls1
{
var $x=100;
var $y=200;
}
$obj= new cls1();
print_r(get_object_vars($obj));
?>Output:
6. class_exists: To check whether the specified class is existed or not.
<?php
class cls1
{
}
echo class_exists("cls1");
?>Output:
7. is_subclass_of: By using this function we can check whether the 1st class is subclass of 2nd class or not.
<?php
class cls1
{
}
class cls2 extends cls1
{
}
echo is_subclass_of("cls2","cls1");
?>Output:
8. method_exists: By using this function we can check whether the class method is existed or not.
<?php
class cls1
{
function fun1()
{
}
}
echo method_exists("cls1","fun1");
?>Output:
