i´m looking for solution for my problem. I´m reading a xml feed which works fine, but sometime 1 node is missing. I always get an error in the logfile. I don´t want to turn off the complete error reporting. Can someone let me know, what´s the best way? Here is my code:
if(isset($im->price->attributes()->amount)) {
$track_amount = $im->price->attributes()->amount;
$track_currency = $im->price->attributes()->currency;
} else {
$track_amount = "0.00000";
$track_currency = "USD";
}
I thought this "if" loop can solve the problem, but the error still appears in the error log.
If you're using the following condition and still getting the warning
if(isset($im->price->attributes()->amount)) {
You're probably not checking the right variable, and since attributes()
is a function which cannot be checked with isset()
, I would suggest you to change the condition to:
if(isset($im->price)) {