Get class and methods of an object – PHP

Use get_class to get the name of an object’s class.

<?php $class_name = get_class($object); ?>

Now, Use get_class_methods to get a list of all the accessible methods on an object

<?php
$class_name = get_class($object);
$methods = get_class_methods($class_name);
foreach($methods as $method)
{
    var_dump($method);
    echo "<br>";
}
?>

2 thoughts on “Get class and methods of an object – PHP

  1. Wow that was unusual. I just wrote an incredibly long comment but after I clicked submit my comment
    didn’t show up. Grrrr… well I’m not writing all that over again. Anyway,
    just wanted to say fantastic blog!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s