Following three (3) listed functions return all related information of an object that may be an ARRAY in PHP.
function print_vars($obj) { foreach (get_object_vars($obj) as $prop => $val) { echo "\t$prop = $val\n"; } } function print_methods($obj) { $arr = get_class_methods(get_class($obj)); foreach ($arr as $method) { echo "\tfunction $method()\n"; } } function class_parentage($obj, $class) { if (is_subclass_of($GLOBALS[$obj], $class)) { echo "Object $obj belongs to class " . get_class($$obj); echo " a subclass of $class\n"; } else { echo "Object $obj does not belong to a subclass of $class\n"; } }
No comments:
Post a Comment