Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print_r to get object methods in PHP?

I'm working with Views 2 in Drupal 6, and I am having difficulty finding documentation on the methods of the View object. Is there any PHP function like print_r that outputs methods as well as fields?

like image 940
Nick Heiner Avatar asked Aug 17 '09 20:08

Nick Heiner


3 Answers

I believe you're looking for get_class_methods. If this is the case, get_class_vars may also interest you.

like image 78
Mathachew Avatar answered Oct 13 '22 08:10

Mathachew


The Reflection API might be of interest to you (if it's not overkill). Specifically:-

<?php
    Reflection::export(new ReflectionClass('View'));
?>

Check out the manual for more in-depth examples.

like image 11
Gavin Gilmour Avatar answered Oct 13 '22 08:10

Gavin Gilmour


Besides the functions mentioned by Mathachew you can also take a look at Reflection, especially the ReflectionClass class.

$class = new ReflectionClass('YourViewClass');
$class->getMethods();
$class->getProperties();
like image 3
Philippe Gerber Avatar answered Oct 13 '22 07:10

Philippe Gerber