For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > November 2007 > &$ in functions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author &$ in functions
Niels Lange

2007-11-30, 4:02 am

Hi guys,

at present I=B4m editing some old scripts from a colleague from mine. In
one function I fund something I didn=B4t understand. The function looks
like:

function foobar(&$val, $key =3D ' ')
{
...
}

Could anyone tell me what the &$ stands for? I tried to find some
informations in Google. But it is really difficult to find some
informations by using "php + &$" as a search string.

Thanks
Erwin Moller

2007-11-30, 4:02 am

Niels Lange wrote:
> Hi guys,
>
> at present I´m editing some old scripts from a colleague from mine. In
> one function I fund something I didn´t understand. The function looks
> like:
>
> function foobar(&$val, $key = ' ')
> {
> ...
> }
>
> Could anyone tell me what the &$ stands for? I tried to find some
> informations in Google. But it is really difficult to find some
> informations by using "php + &$" as a search string.
>
> Thanks


Hi,

read more here:
http://nl3.php.net/manual/en/langua...rences.pass.php

It is passing by reference.

Regards,
Erwin Moller
Kim André Akerĝ

2007-11-30, 4:02 am

Niels Lange wrote:

> Hi guys,
>
> at present I´m editing some old scripts from a colleague from mine. In
> one function I fund something I didn´t understand. The function looks
> like:
>
> function foobar(&$val, $key = ' ')
> {
> ...
> }
>
> Could anyone tell me what the &$ stands for? I tried to find some
> informations in Google. But it is really difficult to find some
> informations by using "php + &$" as a search string.


By using this, you can allow your function to modify the referenced
variable.
http://php.net/language.references.pass

--
Kim André Akerĝ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Niels Lange

2007-11-30, 8:02 am

Hi Erwin and Kim,

thanks for the quick answers!

Regards
Niels
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com