Php 获取对象的值
我不明白。。。我有一个目标:Php 获取对象的值,php,class,object,Php,Class,Object,我不明白。。。我有一个目标: object(stdClass)#7 (12) { ["type"]=> int(0) ["encoding"]=> int(1) ["ifsubtype"]=> int(1) ["subtype"]=> string(5) "PLAIN" ["ifdescription"]=> int(0) ["ifid"]=> int(0) ["lines"]=> int(44) ["bytes"]=> in
object(stdClass)#7 (12) {
["type"]=> int(0)
["encoding"]=> int(1)
["ifsubtype"]=> int(1)
["subtype"]=> string(5) "PLAIN"
["ifdescription"]=> int(0)
["ifid"]=> int(0)
["lines"]=> int(44)
["bytes"]=> int(1078)
["ifdisposition"]=> int(0)
["ifdparameters"]=> int(0)
["ifparameters"]=> int(1)
["parameters"]=> array(1)
{ [0]=> object(stdClass)#8 (2)
{ ["attribute"]=> string(7) "charset"
["value"]=> string(5) "utf-8" } } }
并希望获得参数->最后一行的值
我得到如下参数:
public function get_formated_body() {
return $this->format->parameters;
}
但是我没有得到值字段
我尝试了我脑海中出现的每一种可能性,比如:
return $this->format->parameters->value;
return $this->format->parameters['value'];
还有很多无用的东西
也许你们中的一个有更多的想法。
谢谢 用这个
return $this->format->parameters[0]->value;
用这个
return $this->format->parameters[0]->value;
使用此代码:
return $this->format->parameters[0]->value;
参数是一个数组,值位于位置0使用以下代码:
return $this->format->parameters[0]->value;
参数是一个数组,值位于位置0parameters是一个数组,因此需要添加键。例如:返回$this->format->parameters[0]->value;干杯,就这样。是时候休息一下了@DavidJonesParameters是一个数组,因此需要添加密钥。例如:返回$this->format->parameters[0]->value;干杯,就这样。是时候休息一下了@戴维杰恩斯