PHP中ResultSet取字段值

【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;



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


发布了18 篇原创文章 · 获赞 8 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/qq_20408397/article/details/73008090