Determining a PHP object's name

2019-04-28 19:11发布

In Java (well, Android's version at least) all objects have a getClass() method which returns the object's class and you can then call getSimpleName() to get the human-readable name of the object. This is great for logging. I'd like to be able to do something similar in a PHP program I've been working on. Is there any way to find out what type of object "this" is?

标签: php oop object
2条回答
2楼-- · 2019-04-28 19:18
return get_class($this);
查看更多
Explosion°爆炸
3楼-- · 2019-04-28 19:26

I think this php.net man page may have the answers your looking for: http://php.net/manual/en/function.get-class.php

查看更多
登录 后发表回答