The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

So outside of performance, there's no real advantage to having data stored in an object rather than an array? Just wondering why it is Google pass objects in the first place, whether it allows you to process their data more effectively or something.

In a way, using objects instead of arrays makes more sense. Traditionally (in strongly typed languages), arrays are used to store elements that all have the same type. In PHP this isn't necessary, as you can do this:

In other words, you can define entirely new datatructures using just arrays. The above structure is an array with only 3 elements, but each element is of a different type. If you don't know the array you're working with well, you can't know anything about the elements and their respective types. Objects make much more sense in that case (especially because you can then hide private data). An object always has a type (its class) and the type implicitly defines what kind of structure it has. This is much more logical, and safer as well.

I do use arrays like I portrayed here - they can be very convenient at times - but always locally (to a function or to a class). Some class may store an array with some specialized datastructure, but only that class itself can have access to the array. Passing arrays like these around all over the code is dangerous, I think.

That is completely true. I don't like passing around arrays with data structures because that means other code can access private data directly. However, the fact that PHP doesn't even have private data members in classes and that it's even possible to assign new data members to an object from outside of that object completely negate the advantages of using classes over arrays.

I mean, this:

PHP Code:

$object = new StdClass();// $object is an instance of class StdClass, having no// data members at all, and no methods either.$object->name = 'foo';// Suddenly $object has a new member variable!