关闭
douyulv6921 2011-11-30 12:55
浏览 40
已采纳

给定一个对象数组,如何回显内容?

I have an object array $this->result

When I echo $this->result I get Array.

When I print_r($this->result) I get a blank screen.

How do I find what is being stored in this object array?

EDIT: By blank screen I mean the nothing is being rendered at all.

EDIT2: Here is the code that renders, but I don't know what it's doing.

<?php  
    foreach ($this->result as $r){
        extract($r);
        // Then there is a bunch of code beneath here 
        // that displays different results
   } 
?>

However if I do this, the page no longer renders at all.

    echo '<pre>' . print_r($this->result, true) . '</pre>';

    foreach ($this->result as $r){
        extract($r);
        // Then there is a bunch of code beneath here 
        // that displays different results
   } 

EDIT3:

After installing and turning on xdebug, var_dump now displays the data. (however print_r() still does not). Any thoughts as to why that might be?

  • 写回答

2条回答 默认 最新

  • doudui1850 2011-11-30 13:42
    关注

    If available, honestly I would use a php debugger like xdebug and set up a debugging client and just inspect it. What is the reason for not knowing the contents of the objects in the array?

    print_r when set to true will return the output instead of printing it to the screen.

    what about

    foreach ($this->result as $r){
       print_r($r);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部