简体   繁体   English

PHP-“注意:尝试获取非对象错误的属性”

[英]PHP - “Notice: Trying to get property of non-object error”

I'm getting this 'Notice:Trying to get property of non-object error"... 我收到此“通知:正在尝试获取非对象错误的属性” ...

I have currently this varDump: 我目前有这个varDump:

object(SimpleXMLElement)#1 (1) {
  ["GetCompetitivePricingForASINResult"]=>
  object(SimpleXMLElement)#2 (2) {
    ["@attributes"]=>
    array(2) {
      ["ASIN"]=>
      string(10) "0747587086"
      ["status"]=>
      string(7) "Success"
    }
    ["Product"]=>
    object(SimpleXMLElement)#3 (1) {
      ["Identifiers"]=>
      object(SimpleXMLElement)#4 (1) {
        ["MarketplaceASIN"]=>
        object(SimpleXMLElement)#5 (2) {
          ["MarketplaceId"]=>
          string(13) "ATVPDKIKX0DER"
          ["ASIN"]=>
          string(10) "0747587086"
        }
      }
    }
  }
}

And here is my call for the xml elemtn that gives the error: 这是我对给出错误的xml elemtn的调用:

echo $xmlFile->GetCompetitivePricingForASINResult->Identifier->MarketplaceASIN->ASIN. "\n";

Could anyone advise on what I need to do? 有人可以建议我该怎么做吗? I've done some research online; 我在网上做了一些研究; but it seems case specific... 但似乎是特定情况...

Thanks, 谢谢,

You skipped Product , and you left out the s at the end of Identifiers . 您跳过了Product ,在Identifiers末尾省略了s It should be 它应该是

$xmlFile->GetCompetitivePricingForASINResult->Product->Identifiers->MarketplaceASIN->ASIN

看起来需要是$xmlFile->GetCompetitivePricingForASINResult->Product->Identifiers->MarketplaceASIN->ASIN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM