php 之 Object of class stdClass could not be converted to string
来源:互联网 发布:淘宝买家号开店 编辑:程序博客网 时间:2024/05/16 23:52
今天用Php进行输出时遇到了如下错误:
Catchable fatal error: Object of class stdClass could not be converted to string in……\***.php on line 10
具体错误是语句:echo $result;
从错误说明中可知$result是class stdClass类型,我们用var_dump()函数进行了输出,此函数显示关于一个或多个表达式的结构信息,包括表达式的类型与值。数组将递归展开值,通过缩进显示其结构。 语句为
var_dump($result);
显示结果为:
object(stdClass)#2 (1) { ["return"]=> string(46) "Hello, My Friend!"}
很明显,我们想要输出的结果就是“Hello,My Friend!”,代表的就是这个类对象中return变量的值,因此,我们可用如下语句输出我们想要的值:
echo $result->return;
替代原来的echo $result;
转载本文请注明出处:http://hi.baidu.com/%B9%FA%BC%D9%B2%BB%C2%C3%D3%CE/blog/item/9a79d672460113210dd7da75.html
http://hi.baidu.com/zhouence/item/538b613569c88b96b711db9e
0 0
- php 之 Object of class stdClass could not be converted to string
- Object of class stdClass could not be converted to string
- Object of class classname could not be converted to string
- Object of class DateTime could not be converted to string
- PHP 报错 Object of class mysqli could not be converted to string in
- Error: The INF file contains Unicode characters that could not be converted correctly to ANSI 解决办法
- Error: The INF file contains Unicode characters that could not be converted correctly to ANSI
- Error: The INF file contains Unicode characters that could not be converted correctly to ANSI
- Value of type java.lang.String cannot be converted to JSONObject
- Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONArra
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSON
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
- linux网络编程二:基础socket, bind, listen, accept, connect
- 新长城 郁闷的一道面试题(把C盘文件复制到D盘)
- Oracle 字段类型
- 零佣金面世 互联网金融改写券商经纪版图
- delphi 进程间通信的两种方法
- php 之 Object of class stdClass could not be converted to string
- Java中的Set,List,Map的区别
- 12 Linux下新建用户和切换当前用户
- semaphore---Dijkstra
- 关于wampserver无法启动mysql数据库的问题
- Select函数实现原理分析
- 设计模式-单一职责模式
- Leetcode_spiral-matrix-ii
- Storm中Topology任务调度策略