PHP中ResultSet取字段值

来源:互联网 发布:国家广电网络组织架构 编辑:程序博客网 时间:2024/06/16 19:56

【PHP学习记录】

在PHP阿里的SDK遇到了个函数返回的结果为resultset型的,第一次见,一开始以为是json, 用json_decrypt报错,后来琢磨出了使用方法

上例子:var_dump数据如下

object(SimpleXMLElement)#4 (2) { ["result"]=> object(SimpleXMLElement)#5 (3) { ["err_code"]=> string(1) "0" ["model"]=> string(26) "xxxxxx^xxxxxx" ["success"]=> string(4) "true" } ["request_id"]=> string(12) "xxxxx"}

 从返回结果可以看得出格式有点像json,result下有err_code,model,success三个字段,则

单独取出success字段值:

$str=$resultset->result->success;

取出err_code字段值:

$str=$resultset->result->err_code;



 各位有什么更好的取值方法也可以分享下~