[thelist] another php question: object reference syntax

Tim Parkin tim at pollenation.net
Wed Jul 17 16:52:01 CDT 2002


>I don't know enough PHP to know which operations generate actual copies
and
>which operations generate references. PHP wizards -- I know you're out
>there!
If you use an &before a variable it is recognised as a reference.

So myFunction(&$var); will pass a reference to the $var variable to the
function instead of copying the variable.

Objects are the same leading to some confusion as you can imagine. You
should always use $returned =& new func(); if you want to return
references and not copies.

See :

http://www.php.net/manual/en/language.oop.newref.php

Tim
PollenationInternet





More information about the thelist mailing list