Re: [PHP4BETA] Session: objects containing objects
| From: | Ulf Wendel | Date: | Thu, 24 Feb 2000 15:22:58 +0000 |
| Subject: | Re: [PHP4BETA] Session: objects containing objects | ||
| References: | 1 2 3 4 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-10855@lists.php.net to get a copy of this message | ||
Boris Erdmann wrote:
> This script saves a session with an object containing an object.
> The first time this script is started it instantiates the object
> $obj from class foo, which then contains an object $obj->foo_bar
> from class bar. $obj->foo_bar then contains a slot "bar_foo" which
> gets initialized to "no success". Just after instantiating $obj its
> child object's slot gets changed to "success". This is the printout
> when you restart the script by klicking "klick".
Hey, great. I don't have php4 installed anywhere not even on my
windows, so I could'nt try it out myself.
> class name of an object. (Showing one of the typical inconsistencies in
> php: two merried functions with different syntax - yes i am talking
> about the underscore)
:-) - see your reaction on get_member_vars().
> Now: together with the ability of walking through an object via
>
> reset($obj); while ( list($slot) = each($obj) ) { you_name_it; }
>
> you have the three functions/methods you requested for
> basic introspection.
I know I can tread an object like an array to find out on it's
slots - but: will it work in PHP5 (5.01, 4.x) the same way, is
this feature documented? We should rather implement a function
for this purpose.
Boris, do you have any experiences with constructors and
sessions? PHPLIB can't handle the following code, how about php4?
<?php
class foo() {
var $mode;
function foo( $mode ) {
$this->mode = $mode;
}
}
$sess->register("foo");
?>
PHPLIB would need a new slot $constructor_param() = array() that
gets filled by the constructor of foo to be able to serialize the
object. Or I get yet another function: get_constructor() ...
Ulf
--
Ulf Wendel
NetUSE Kommunikationstechnologie GmbH
Siemenswall, D-24107 Kiel, Germany
Fon: +49 431 386435 00 -- Fax: +49 431 386435 99