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

Unit 8: Objects



            $lineage = get_lineage($object);                                                      Notes
            array_pop($lineage);
            echo count($lineage) ? (‘<p>’ . join(‘ -> ‘, $lineage) . ‘</p>’) : ‘<i>None</i>’;

            echo ‘<h3>Children</h3>’;
            $children = get_child_classes($object);
            echo ‘<p>’ . (count($children) ? join(‘, ‘, $children) : ‘<i>None</i>’) . ‘</p>’; echo ‘<h2>Methods</
            h2>’;
            $methods = get_class_methods($class);
            $object_methods = get_methods($object);
            if(!count($methods))

            {
            echo “<i>None</i><br />”;
            }
            else {

            echo ‘<p>Inherited methods are in <i>italics</i>.</p>’;
            foreach($methods as $method)
            {
            echo in_array($method, $object_methods) ? “<b>$method</b>( );<br />” : “<i>$method</i>( );

            <br />”;
            }
            }
            echo ‘<h2>Properties</h2>’;

            $properties = get_class_vars($class);
            if(!count($properties))
            {
            echo “<i>None</i><br />”;

            }
            else
            {
            foreach(array_keys($properties) as $property)

            {
            echo “<b>\$$property</b> = “ . $object->$property . ‘<br />’;
            }
            }

            echo ‘<hr />’;
            }




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