Re: [PHP4BETA] Session: objects containing objects
| From: | Boris Erdmann | Date: | Thu, 24 Feb 2000 18:28:44 +0000 |
| Subject: | Re: [PHP4BETA] Session: objects containing objects | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-10888@lists.php.net to get a copy of this message | ||
Ulf Wendel wrote:
>
> Andrei Zmievski wrote:
> >
> > On Thu, 24 Feb 2000, Ulf Wendel wrote:
> > > get_member_vars() sounds good, although I prefer slots or fields.
> > Ok, just a little more thinking. Do you really need a function? Can't
> > you use foreach() or each() to iterate over them?
>
> Yes, I can. But as far as I know this feature is not documented
> and more important will PHP5 beahave the same way?
>
> I would like to see
> php to break with hacks. It's not very common that you can tread
> an object like an array. An object is completely different from
> an array, isn't it?
>
Well, this is questionable. Semantically they are different. But
they are often implemented in similar ways. Another popular example
is JavaScript where you cant really draw a line between arrays and
objects since arrays are alway methodless objects. Thus you have both
notations for accessing array and objects. there is no difference
between
object.slot
object["slot"]
array["key"]
array.key
This leads to another question: why cant we make this possible in php?
if $obj->slot could be written as $obj["slot"], then $obj[$varslot]
would be possible, too (and is widely use in JavaScript), and we would
have in praxis $obj->$varslot, which wont work today in php4. But why -
$arr[$varkey] works!!
Does this lead too far... ?
Boris
--
Only try to realize the truth! - What truth? - There is no spoon. [Matrix]