Posted by Bogdan Ribic on 01/22/06 00:23
> I have a question about using $this as an argument in a method.
As I understand it, the only issue here is if you are passing $this
from constructor of your class from PHP 4. In short, when you do
$var = new MyClass();
you are actually storing a copy of what constructor was seeing as
$this, and if you passed $this from constructor to an outside function
that stores it somewhere, then you now have two different objects. Way
to circumvent this is to use
$var = & new MyClass();
ie, use a reference, or make sure that your script will be running on
PHP5. If you do the above thing with reference in PHP 5 though, you will
get a warning that this is deprecated.
Hope this helps...
Open source PHP code generator for DB operations
[Reply to this message]