← back to the blog


Get methods of an object PHP

Posted on September 22nd, 2019 in PhP by George

 

 Easy way to inspect the available methods of an object in PHP by using get_class and get_class_methods built-in functions.

 

get_class — Returns the name of the class of an object

get_class_methods — Gets the class methods' names

 

<?php

//Get the class nmae of the object
$class_name = get_class($object);


//$using the class name get the available methods on the object instance

$methods = get_class_methods($class_name);

//error log the methods

error_log(print_r($methodsr,true));

?>