A reflect() Function For Quick Reflection in PHP

Tuesday, January 5th, 2010

Tags:

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:

 
<?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 Response to “A reflect() Function For Quick Reflection in PHP”

  1. [...] Visit link: A reflect() Function For Quick Reflection in PHP « maSnun.com [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">