RE: [SMARTY-DEV] RE: [SMARTY] php5 Iterators.
[email protected] (David Zülke)
| Newsgroups | php.smarty.dev |
|---|---|
| Organization | bitXtender GbR |
| Message-ID | <[email protected]> |
Wait a minute
Couldn't we just change the array casting so it is only performed if the
variable is _not_ an object?
foreach($object as $key => $ value) {}
is the same as
foreach((array)$object as $key => $ value) {}
Both will loop over the properties of an object.
It will also work in PHP5. If there's an iterator defined, PHP will use it,
if not, it will loop over the properties just like in the good old times.
I think I either got something wrong in here or back last Monday when I said
it wouldn't be possible to do this.
Any objections?
David
> -----Original Message-----
> From: Mark Rogers [mailto:[email protected]]
> Sent: Monday, January 24, 2005 10:48 AM
> To: [email protected]
> Cc: boots
> Subject: Re: [SMARTY-DEV] RE: [SMARTY] php5 Iterators.
>
> Boots writes:
> > My point is that the current compiler isn't really well suited to spit
> > out different code for different targets. If the compiler were a bit
> > more plugable it would be far easier to swallow since only code
> > appropriate for your platform would be loaded. As it is, I suspect that
> > this will only add further bloat to good 'ol foreach which is already a
> > little overworked. I'm not against it, I'm just suggesting that it may
> > make sense to keep the PHP4 and PHP5 features more separated.
>
> {iterate}?
>
> We already have {section} and {foreach}, which are substantially similar
> and
> which essentially perform the same task on different types of array.
> Whilst
> I'm not convinced this is necessarily a good thing, it is the status quo
> and
> {iterate} is more in keeping with what's there now. Or perhaps {foreach
> mode=iterate}, which has the benefit of not declaring a new tag (I can see
> {iterate} being used already by some Smarty users).
>
> --
> Mark Rogers,
> More Solutions Ltd
>
> --
> Smarty Development Mailing List (http://smarty.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>