NYCPHP Meetup

NYPHP.org

[nycphp-talk] What does function &get_ref() {} do?

Peter Lehrer pl at eskimo.com
Wed Sep 3 22:52:47 EDT 2003


What you are doing is passing a reference to $var_1 and $var_2. In this way,
you can change the values of these variables outside the scope of the
function.

Peter L.
----- Original Message -----
From: "Michael Southwell" <southwell at dneba.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Wednesday, September 03, 2003 9:03 AM
Subject: Re: [nycphp-talk] What does function &get_ref() {} do?


> Here is the relevant portion of Jon's reference (illustrating &$var):
> -------------------------
> function swap(&$var_1, &$var_2)
> {
>    $temp = $var_1;
>    $var_1 = $var_2;
>    $var_2 = $temp;
> }
>
> $var_1 = 'I am var 1';
> [etc]
> -----------------------------
>
> doesn't this need global $var_1,$var_2; in the swap function?
>
>
> At 01:42 AM 9/3/2003, you wrote:
> >this explains it pretty well ...
> >
>
><http://www.faqts.com/knowledge_base/view.phtml/aid/134/fid/40>http://www.f
aqts.com/knowledge_base/view.phtml/aid/134/fid/40
> >
> >- jon
> >----- Original Message -----
> >From: <mailto:soazine at erols.com>Phil Powell
> >To: <mailto:talk at lists.nyphp.org>NYPHP Talk
> >Sent: Wednesday, September 03, 2003 3:16 AM
> >Subject: [nycphp-talk] What does function &get_ref() {} do?
> >
> >I've seen the notation '&' floating around prefixing function names from
> >time to time but I can't find any online resource that explains what it
> >does.  Can someone explain it to me?
> >
> >Thanx
> >Phil
> >
> >
> >----------
> >_______________________________________________
> >talk mailing list
> ><mailto:talk at lists.nyphp.org>talk at lists.nyphp.org
> >http://lists.nyphp.org/mailman/listinfo/talk
> >
> >_______________________________________________
> >talk mailing list
> >talk at lists.nyphp.org
> >http://lists.nyphp.org/mailman/listinfo/talk
>
> Michael G. Southwell =================================
> DNEBA Enterprises
> 81 South Road
> Bloomingdale, NJ 07403-1419
> 973/492-7873 (voice and fax)
> southwell at dneba.com
> http://www.dneba.com
> ======================================================
>
>
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk
>




More information about the talk mailing list