Determining a PHP object's name

霸气de小男生 提交于 2020-01-02 03:29:08

问题


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?


回答1:


return get_class($this);



回答2:


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



来源:https://stackoverflow.com/questions/1976160/determining-a-php-objects-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!