douhui8163 2014-02-26 05:44
浏览 55
已采纳

解析错误:类stdClass的对象无法转换为字符串

I'm using twitter api to retrieve fav tweets, then parse them using a template:

$favs_list = $this->connection->get('favorites/list');
$data_to_parse['fav_list'] = $fav_list;
$html = $this->parser->parse('templates/tweet_list', $data_to_parse, TRUE);
$output['html'] = $html;
$this->load->view('read', $output);

the template tweet_list is simply:

<h3>Favs:</h3>
{fav_list}
<h5>{text}</h5>
{/fav_list}

But I keep getting these two error, and repeated multiple times:

A PHP Error was encountered    
Severity: 4096     
Message: Object of class stdClass could not be converted to string     
Filename: libraries/Parser.php
Line Number: 143

A PHP Error was encountered   
Severity: Notice     
Message: Object of class stdClass to string conversion     
Filename: libraries/Parser.php    
Line Number: 143

The weird thing is that, under these errors, my html is shown in correct format. Any idea on what caused this?

  • 写回答

2条回答 默认 最新

  • dpdhf02040 2014-02-26 10:12
    关注

    I don't know optimal method but I do usually with

    json_decode(json_encode ($favs_list), true);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题