Posted by Mortimer on 07/19/07 11:54
Scriveva gosha bine giovedì, 19/07/2007:
> On 19.07.2007 12:26 Mortimer wrote:
>>> I've noticed in your first example you didn't assign anything to
>>> MySecondClass->$obj, perhaps that is the problem ;)
>>
>> Sorry, i didn't write it, but i assign the object in the constructor, like
>> this:
>>
>> class Session {
>> private $db;
>> function __construct($db) {
>> $this->db = $db;
>> }
>> function __destruct() {
>> echo "Destroyed Session\n";
>> }}
>>
>> Uhm.. thank you
>>
>>
>
> I'm lost now. :-o
>
> What does this print for you?
>
>
> class Database {
> function __destruct() {
> echo "Destroyed Database\n";
> }}
> class Session {
> private $db;
> function __construct($db) {
> $this->db = $db;
> }
> function __destruct() {
> echo "Destroyed Session\n";
> }}
> $db = new Database;
> $sess = new Session($db);
> die();
This prints
Destroyed Database
Destroyed Session
:\
[Back to original message]
|