3. Write a PHP script to demonstrate the
introspection for examining class(use function get_declared_classes()
,get_class_methods() and get_class_vars()).
Php
file :
<?php
class
intro
{
var $i;
function f1() {}
function f2() {}
}
class intro_1 extends intro
{
var $j,$k;
function f3() {}
function f4() {}
}
echo class_exists('intro'); //returns true if class is exist
var_dump(get_declared_classes()); //returns an array of all the class are
define & declared in php including classes name
var_dump(get_class_methods('intro_1')); //returns an array of methods in class
intro_1
var_dump(get_class_methods('Exception')); //returns an array of methods in class
Exception
var_dump(get_class_vars('intro_1')); //returns parent class of given class
intro_1 if it is exists
var_dump(get_parent_class('intro_1')); //reurns parent class of given class if
it exist
var_dump(get_object_vars($ob)); //retuns an array of parameter / variables
for given object
?>
I am confused about output.
ReplyDeletecan you mail me the output which you have obtained from this programe
Thanks In Advance.
8044amol@gmail.com
DeleteSir in this program you cannot define ob;
ReplyDeletethat why u define one object of class like
$ob=new intro;
this line add after class declaration......
I think u are not reading the program correctly. It is about examining class not an object, so why should we declare object??
Delete