Forum Moderators: coopster

Message Too Old, No Replies

What's so great about stdClass?

objects vs arrays

         

cameraman

7:41 pm on Jul 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I started doing object oriented programming in C++ right at 20 years ago and I definitely like classes where they're appropriate. I'm comfortable with it and I understand the concepts.

Right now I'm writing a wrapper class for imap, and what I'm not understanding is why so many of the imap functions return stdClass objects - what's the advantage? I'd just as soon they return associative arrays; they're a whole lot easier to run through.

What is the advantage of a class that has variables but no member functions? What am I missing?

cameraman

8:01 pm on Jul 12, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok I just ran across object iteration [php.net] which is a whole lot easier than the way I was getting properties out via Reflection, but I still don't see why you wouldn't just return an assoc array...