You are here: Passing by reference, assigning by reference? « PHP « IT news, forums, messages
Passing by reference, assigning by reference?

Posted by Alex Gemmell on 09/05/05 13:24

Hi sports fans!

I have a quick "references" related question.

Ok, I'm passing a Page object by reference to another object:

myClass->myFunction($objPage);

What I want to do is store that Page object as part of the myClass
object (see definition code below).

My question is this: When assigning the Page object to be a variable of
the myClass object do I store a reference to it or a copy of the reference?

class myClass()
{
var $objPage;

function myFunction(&$objPage) {
// this way (a reference to the reference?):
$this->objPage =& $objPage;

// or this way (a copy of the reference?):
$this->objPage = $objPage;

// code, code, code...
}
}

Is there much difference? Does it really matter? I'm unsure if this is
efficient or not.

Can someone please shed some light on this.

Thanks!

 

Navigation:

[Reply to this 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

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