Mukul Sabharwal wrote:

And the error is strange because you're doing
something strange!

I don't think I'm doing anything strange. What I have exposed here is a simplification of my own class loader. I have the main class that must load (include and then instance) other PHP classes.
The problem is that if I do instance other classes in the loader constructor they get a "copy" of the loader instance and not the real instance reference.


[some your code snipped]
$base = new base_class;
$second = new second_class($base);

$second->foo->some = 100;
// here it is, base_class' some is accessible

I know. If you give a closer look to my own code, you'll see that there is a line (commented) doing almost the same thing as you. But I need something else.


Infact, look at the end of my code, there are these two lines:

$b = new base_class ();
// $b->create ();               // This line works

if I instance the base_class and outside the constructor i do the create (as shown in the second line) everything works. And I am actually just sending ($this) as the argument (look inside the create method code),
in exactly the same way I was doing in the base_class constructor.
The problem is that inside the constructur THE SAME CODE DOES NOT WORK.


I think it's a bug. I have worked around it by doing the two calls, but I would like to know if it is a real bug or just me doing something wrong.

Ciao,

Fabio


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to