PHP is like a kindly old aunt who doesn’t like to correct the young’ins even though she knows they’ve done wrong. In her head, she’s saying “Oh, so-and-so, that’s so cute,” while in her head she’s sadly contemplating the genetic lottery that led someone to try to fetch an object property from a variable that isn’t an object at all.
But what is an object in PHP?
And as you can see, the fix is as simple as can be: Here’s a final example of an externally sourced piece of data that occasionally threw a log notice about trying to get a property on a non-object: On the surface it seems well and good: there’s even a check for whether the json_decode() worked in line 12.
Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox.Explore