Reply to Re: Three different ways to create a new Smarty object?

Your name:

Reply:


Posted by Chung Leong on 05/19/06 01:36

rockstar wrote:
> The last one, I BELIEVE is creating a reference. I don't completely
> understand php references (as my "mentor" of sorts doesn't really
> either), but I've never had a need to use =&, and it seems to me to be
> a hack rather than serve a good purpose. Stick with the middle one,
> and it'll make everything much cleaner.
>
> Paul
> http://eventuallyanyway.com

In this instance the use of =& is probably useless. There are specific
situations though where you must use it. Say you have the following:

class Node {
var $parent;
var $child;

function Node(&$parent) {
$parent->child =& $this;
}
}

$node = new Node($parent);

Because the = operator is assignment by-value, a copy of the new object
is assigned to $node. Thus $node and $parent->child end up pointing to
different objects, unlikely to be the desired result.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация