View Single Post

  #6 (permalink)  
Old 05-23-2006
kasztelix@gmail.com
 
Posts: n/a
Default Re: Three different ways to create a new Smarty object?


Chung Leong napisal(a):
> It's redundant. = and =& do the same thing. The author does it either
> because he doesn't understand PHP's copy-on-write mechanism or he
> trying to be consistent between PHP 4 and PHP 5, where objects are
> always assigned by reference.


I belive it is not redundant. Look here:
http://uk.php.net/manual/en/language...ces.whatdo.php

Not using the & operator causes a copy of the object to be made. If you
use $this in the class it will operate on the current instance of the
class. The assignment without & will copy the instance (i.e. the
object) and $this will operate on the copy, which is not always what is
desired. Usually you want to have a single instance to work with, due
to performance and memory consumption issues.

While you can use the @ operator to mute any errors in the constructor
when using it as @new, this does not work when using the &new
statement. This is a limitation of the Zend Engine and will therefore
result in a parser error.

Reply With Quote