Re: question about using $this as a method in a function argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>
> 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...

Boban.

--

   Open source PHP code generator for DB operations
   http://sourceforge.net/projects/bfrcg/

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux