Wednesday, July 11, 2012

How to figure out what a variable really is?

Wow it's been a while since I posted on this blog! I came across a stupid error today (the error wasn't stupid, I was...) where I needed to use an object in a function, but for some reason, PHP didn't think it was an object.

Eventually I used: gettype, then get_class, even tried a little is_object.  Of course all of them returned that it was indeed an object, it was the class I thought it was, and yes.. no really.. it's an object.  No matter what I tried however, any get call failed.
Turned out I was using said function in a couple places, and RIGHT BEFORE I needed it, I was setting that var to an array, then back to an object. It was failing on the array call, and not even in the place I thought it was failing.

Welp.. now I know to scroll back and read the ENTIRE log instead of tailing the last few lines.


 

Made by Lena