I get some user information from linked api as json objects. I parse the json using json_decode method. It works just fine. My problem is when a field doesn't exist in the json. For example position object sometimes won't have the endDate property.
$endDate = $user->positions->values[$i]->endDate->year."-".$user->positions->values[$i]->endDate->month."-01";
when the endDate property doesn't exist it gives me the undefined propery error. and code fails. I tried to use try catch but it still gives the error in try. im a newbie php coder. How should I detect that a property is undefined before making a call to that property?