The Reflection API is the perfect way to reverse engineer and inspect php objects and functions. I have written a function to quickly pass params to the Reflection API and get things done.
Here’s the source codes:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<?php function reflect($data,$return = false) { $string = "\n \nReflecting: {$data} \n"; $string .= "\n====================\n"; if(is_object($data)) { $string .= Reflection::export( new ReflectionClass($data), true ); $string .= "\n====================\n"; } else { if(function_exists($data)) { $string .= Reflection::export( new ReflectionFunction($data), true ); $string .= "\n====================\n"; } } if($return) { return $string; } else { echo $string; } } ?> |
One reply on “A reflect() Function For Quick Reflection in PHP”
[…] Visit link: A reflect() Function For Quick Reflection in PHP « maSnun.com […]