Tuesday, November 12, 2013

PHP, dump all the defined classes and methods





PHP function get_declared_classes is used to return an array with the name of the defined classes
To dump all the defined classes,
<?php
print_r(get_declared_classes());
 ?>

or

<?php

  foreach(get_declared_classes() as $class) 
      echo $class.'<br />';

?>

To dump all the defined methods form class Students,
<?php
print_r(get_class_methods());
 ?>

or

<?php

  foreach(get_class_methods() as $method) 
      echo $method.'<br />';

?>

To dump all the defined variables form class Students,
<?php
print_r(get_class_vars());
 ?>

or also print out its value

<?php

  foreach(get_class_vars() as $var=>$value) 
      echo  "{$var}: {$value}.<br />";

?>
 

No comments:

Post a Comment