douyulv6921 2011-11-30 20: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 21: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条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?