AW: [PHP-WIN] doing $mc=new myclass(); or $mc= &new myclass(); ?

From: Date: Fri, 06 Jun 2003 10:21:06 +0000
Subject: AW: [PHP-WIN] doing $mc=new myclass(); or $mc= &new myclass(); ?
Groups: php.windows 
Request: Send a blank email to php-windows+get-20219@lists.php.net to get a copy of this message
Hi Peter, with new() logically this doesn't make any difference because PHP is using the reference concept anyway. $b = &anything tells PHP to get hold of final effective "anything" and if it evaluates to something referenceable: _not_ build a copy of it and then set variable "b" to reference it. This is conceptual. If you want to know if &new() is 'cheaper' than new() you might want to ask the developers list or take a look at execution time for 10000 [&]new()s or so. Thus $a = 1; $b = $a; $a = 2; echo $b; // will show 1 because the value of $a is copied to form a new value and then variable "b" is set to reference it. //Whereas $a = 1; $b = &$a; $a = 2; echo $b; // will show 2 because $a and $b reference the identical value instance. $a = &any_constant; // is forbidden because constants can not be referenced at all. You have to ask PHP to do $a = any_constant; so it can form a value of the constant and then set $a to reference it. Hope this helps -- Sven > -----Ursprüngliche Nachricht----- > Von: Peter Misun [SMTP:misun@microstep-mis.com] > Gesendet am: Freitag, 6. Juni 2003 11:23 > An: php-windows@lists.php.net > Betreff: [PHP-WIN] doing $mc=new myclass(); or $mc= &new myclass(); ? > > << Datei: ATT00004.g95; charset = iso-8859-2 >>

« previous php.windows (#20219) next »