dongnachuang6635 2011-06-27 20:20
浏览 88
已采纳

查看PHP类实例(对象)以查看其所有可用公共属性和方法的最佳方法是什么?

Sorry, newbie question here but anyways,

I'm trying to use the Google Data API to work with some Google Spreadsheets and I'm trying to use var_dump to look at the structure of the objects I'm receiving from its API calls. I tried using var_dump but it's not giving me what I expect. Most of the properties that it shows me show up as protected like this:

...

["_entryClassName:protected"]
...

and I've tried looking at examples of how the objects properties are being accessed and for the properties that I can actually access with the property access operator (->) I don't even see them in the var_dump output.

So, I'm really confused and I was wondering what is the best way for me to know what are the public properties and methods of my class instance and how many of them are there?

Thanks for any help in advance.

  • 写回答

5条回答 默认 最新

  • duan02468 2011-06-27 20:30
    关注

    I think you want PHP's ReflectionClass which returns information about a class definition at runtime.

    The getMethods function for example accepts parameters to determine whether it should return information about private, protected, public, static methods etc. Although as it says on php.net,

    This function is currently not documented; only its argument list is available.

    I'm not sure how full the rest of the ReflectionClass documentation is, but this makes me think you may want to get ready for a bit of hacking around to achieve exactly what you want.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 spring后端vue前端
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题