Re: Goofy interactions between $this and vars in classs. 4.1.0

From: Date: Mon, 17 Dec 2001 08:26:12 +0000
Subject: Re: Goofy interactions between $this and vars in classs. 4.1.0
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-77921@lists.php.net to get a copy of this message
Hello Mark, Monday, December 17, 2001, 11:05:15 AM, you wrote: M> However, if I Change the Zabba function to: M> function Zabba() M> { M> $localVariable = $this; M> $localVariable->addValue("asdfasdfasdf"); M> } M> Then I will get on output, a NULL array. M> Why is this? Is there any particular reason this happens? Yes, there is. When you do $localVariable = $this, a new object in $localVariable is born. This object definitely dies at the function end, so you get nothing in return. To make the things work properly, you'd need a reference to the $this object, hence the expression should be $localVariable =& $this. But don't forget, that the things will change with the new Zend engine coming and PHP 5 (I suppose). -- Best regards, Maxim Derkachev mailto:max.derkachev@books.ru System administrator & programmer, Symbol-Plus Publishing Ltd. phone: +7 (812) 324-53-53 www.books.ru, www.symbol.ru

« previous php.general (#77921) next »