[wp-hackers] PHP Coding Practices
Robert Deaton
false.hopes at gmail.com
Wed Feb 15 17:05:36 GMT 2006
On 2/15/06, David House <dmhouse at gmail.com> wrote:
> On 15/02/06, Robert Deaton <false.hopes at gmail.com> wrote:
> > Actually, that's a typecast. Try using an explicit one in the code,
> > you'll notice that it runs the same.
>
> So for all extents and purposes you can iterate an object in PHP4.
You could say it, but its not really true, what you can do is typecast
an object to an array and iterate the array, and it will (most likely)
have what you expect, assuming that you're not trying to set iterator
properties like you could in PHP5. The point here being that, yes, we
can safely use the (array) typecast right now anywhere we are doing a
foreach(), even on objects, since we are supporrting PHP4. In the
future, if support for PHP4 is ever dropped (this is like...a few
years off I'd imagine, but since someone mentioned it), at the point
where someone wants to iterate an object with new code, they simply do
not add the typecast, it is not being forced upon them. Make a comment
saying that its an object, not an array, and move along.
--
--Robert Deaton
http://somethingunpredictable.com
More information about the wp-hackers
mailing list