开发者

PHP getting information about an object

If I have an object, how can I know the details of the object. Li开发者_开发知识库ke the file in which it is defined, its methods, properties etc.


You can use PHP reflection functionalities

$class = new ReflectionClass('MyClass');
echo $class->getFileName()."\n";
var_dump($class->getMethods());
var_dump($class->getProperties());

Edit:

ReflectionClass is used on classes and ReflectionObject on objects.


Reflection

If you want something simpler, there's get_class_methods(), get_object_methods(), get_class_vars(), get_object_vars(), etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜