2011年9月16日星期五

Lorna Mitchell's Blog: ArrayAccess vs ArrayObject


Lorna Mitchell has a new post to her blog explaining ArrayObject and ArrayAccess and how each is used.



I help people qualify for Zend Certification and in the last few months I've had questions about both ArrayAccess and ArrayObject. This post is an attempt to illuminate both. In very simple terms, ArrayAccess is an interface, which you can implement in your own objects; ArrayObject, on the other hand, is a class, which you can either use or extend.


She give an example of ArrayAccess - a simple class that implements it to make it work like an array. For ArrayObject, she describes some of the things it comes with, including automatically implementing the ArrayAccess, Countable and Traversable interfaces making it a "more powerful array" type.

没有评论:

发表评论