Re: doing $mc=new myclass(); or $mc= &new myclass(); ?

From: Date: Fri, 06 Jun 2003 13:08:36 +0000
Subject: Re: doing $mc=new myclass(); or $mc= &new myclass(); ?
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-20227@lists.php.net to get a copy of this message
here is answer I was waiting for: Per Lundberg wrote: > On Fri, 2003-06-06 at 14:17, Peter Misun wrote: > > > but I couldn't find case, in which is better to use the first form > > why should I have copy, if there is an original where I'm not having > > control over it ?!? > > You shouldn't. This situation comes from the fact that = by default in > PHP4 does object copying. This is very bad, yes, and it is going to be > changed in PHP5. In other words, in PHP5, $mc = new myclass() will be > equal to $mc = &new myclass(); Until PHP5 is released, we will have to > implicitly specify that we want to create a reference and not a copy of > the object. 5o Peter Misun wrote: > need help: > what do you suggest to use: > > $mc = new myclass(); > or > $mc = &new myclass(); > > because in any tutorial I can see the first form, but on page "what references do" in > PHP manual I found out the second form > > so? > > 5o -- Mgr. Peter Misun MicroStep-MIS, Ilkovicova 3, 841 04 Bratislava, Slovakia tel: +421/ 2/ 602 00 127, 111, fax: +421/ 2/ 602 00 180

« previous php.windows (#20227) next »