Page 196 - Open Soource Technologies 304.indd
P. 196

Web Technologies-I



                   Notes         $parent_methods = get_class_methods(get_parent_class($object));
                                 $methods = array_intersect($methods, $parent_methods);
                                 } return $methods;

                                 } // return an array of superclasses function
                                 get_lineage($object)

                                 {
                                 if(get_parent_class($object))
                                 {
                                 $parent = get_parent_class($object);

                                 $parent_object = new $parent;
                                 $lineage = get_lineage($parent_object);

                                 $lineage[] = get_class($object);
                                 }
                                 else {
                                 $lineage = array(get_class($object));

                                 } return $lineage;
                                 } // return an array of subclasses function
                                 get_child_classes($object)

                                 { $classes = get_declared_classes( );
                                 $children = array( );
                                 foreach($classes as $class)

                                 {
                                 if (substr($class, 0, 2) == ‘_ _’) { continue;} $child = new $class;
                                 if(get_parent_class($child) == get_class($object))

                                 {
                                 $children[] = $class;
                                 }

                                 } return $children;
                                 } // display information on an object function
                                 print_object_info($object)

                                 { $class = get_class($object);
                                 echo ‘<h2>Class</h2>’;
                                 echo “<p>$class</p>”;

                                 echo ‘<h2>Inheritance</h2>’;
                                 echo ‘<h3>Parents</h3>’;



        190                               LOVELY PROFESSIONAL UNIVERSITY
   191   192   193   194   195   196   197   198   199   200   201