Now does var_dump() get class function names?
class animal
{
var $type;
var $says;
function __construct($_type)
{
$type = $_type;
}
function 开发者_JS百科Does_he_think_hes_the_boss()
{
return ($type == 'cat');
}
} // animal
$dog = new animal('dog');
var_dump($dog);
gives
object(animal)[1]
public 'type' => null
public 'says' => null
I'd like to get as much info as I can about a class (for debugging porpoises) - names of variables, names of functions (with their signatures, if possible), parent class, if any, etc ...
How much info can I get from an object?
You can retrieve all detailed information you need about object using reflection
You can look into debug_backtrace()
function dump( $var ) {
$result = var_export( $var, true );
$loc = whereCalled();
return "\n<pre>Dump: $loc\n$result</pre>";
}
function whereCalled( $level = 1 ) {
$trace = debug_backtrace();
$file = $trace[$level]['file'];
$line = $trace[$level]['line'];
$object = $trace[$level]['object'];
if (is_object($object)) { $object = get_class($object); }
return "Where called: line $line of $object \n(in $file)";
}
精彩评论