php utility functions for objects
// utility functions
function print_methods($obj) function class_parentage($obj, $class)
function print_vars($obj)
{
foreach (get_object_vars($obj) as $prop => $val) {
echo "\t$prop = $val\n";
}
}
{
$arr = get_class_methods(get_class($obj));
foreach ($arr as $method) {
echo "\tfunction $method()\n";
}
}
{
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";
}
}
0 ResponsesLeave a comment ?