开发者

how to remove notice error from this code without using @-operator?

开发者 https://www.devze.com 2023-02-13 16:21 出处:网络
I want to remove the notice error? how can i remove it without using the @-operator? if($result->CreateResult->RateAccessorials->RateAccessorialItem!=null

I want to remove the notice error? how can i remove it without using the @-operator?

if($result->CreateResult->RateAccessorials->RateAccessorialItem!=null

Error:

Error:Notice: Undefined property: stdClass::$RateAccesso开发者_StackOverflowrialItem in /some/path/SaiaSecure.php on line 333


PHP's isset construct does exactly this.

if(isset($result->CreateResult->RateAccessorials->RateAccessorialItem)){
  // ...
}

The above code presumes two conditions for correct operation:

  • That $result->CreateResult->RateAccessorials is always set
  • That $result->CreateResult->RateAccessorials is always an object

Edit: I've answered for the sake of question. As a StackOverflow user, it is your duty to select an answer and mark it as such.


In php Checking value is set or not.Use isset function in php

0

精彩评论

暂无评论...
验证码 换一张
取 消