How to check if a nested property exists in SimpleXML

I would like to get rid of the "Try to get information about a non-object" warnings, but could not find the correct syntax to check for the existence of properties in my case.

$this->nonce = $syncbod->Status->Chal->Meta->NextNonce;

Attempt to call

property_exists($syncbod, "Status->Chal")

returns always false. What would be the right way to check if there is one Chal?

+5
source share
1 answer

You should look isset

See question , although the question is about arrays, the same principle applies to SimpleXml properties. The question was rather a reference to the nested part, and then to the array

+3
source

All Articles