Re: when $a = &new class is necessary

From: Date: Mon, 24 Sep 2007 15:54:28 +0000
Subject: Re: when $a = &new class is necessary
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-48160@lists.php.net to get a copy of this message
Gregory Beaver wrote:
As the push to make the PHP 4 code closer to PHP 5 E_STRICT takes place, I thought it might be helpful to have a guide for when $a = &new class is necessary, and when & is necessary for function parameters that are objects.
I agree with the point raised by Justin Patrin that dealing with references are somewhat risky if you are not careful. To reduce this risk and help package owners who want to make their PHP4 packages "PHP5-friendly", it may be worth introducing a utility function that handles the delicate art of handling PHP4 references. For example replace "$foo =& new Bar($bla)" with "$foo =& PEAR::makeNew('Bar', $bla)". This isn't pretty, but it is less likely to have unknown side effects that just replacing "$foo =& new Bar" with "$foo = new Bar". Christian

« previous php.pear.dev (#48160) next »