dpiuqwwyu187975836 2015-02-17 22:07
浏览 52
已采纳

Codeigniter在获取对象的属性时获取非对象错误

I'm trying to get some information of an object. When I var_dump it, I get this:

var_dump($data)

object(stdClass)#44 (3) { 
    ["front_image"]=> string(19) "1424188887front.jpg" 
    ["back_image"]=> string(18) "1424188887back.jpg" 
    ["detail_file"]=> string(16) "1424188887detail.pdf" 
}

I'm trying to get the front image with

echo $data->front_image;

It echos 1424188887front.jpg followed by

A PHP Error was encountered

Severity: Notice
Message: Trying to get property of non-object
Filename: test.php  
Line Number: 198

I'm not sure what's going on. The information is printed without a problem.

  • 写回答

1条回答 默认 最新

  • dongyongju9560 2015-02-17 22:13
    关注

    The information was actually being passed in through an array with multiple $data objects.

    One of them was missing a front_image property so that was why it was spitting out an error.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 iOS 自定义输入法-第三方输入法
  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译