You are here: Re: question about using $this as a method in a function argument « PHP « IT news, forums, messages
Re: question about using $this as a method in a function argument

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

Boban.

--

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация