Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "&" mean here in PHP?

Tags:

Consider this PHP code:

call_user_func(array(&$this, 'method_name'), $args);

I know it means pass-by-reference when defining functions, but is it when calling a function?

like image 546
omg Avatar asked Jun 17 '09 12:06

omg


People also ask

What does the fox say Meaning?

Speaking of the meaning of the song, Vegard characterizes it as coming from "a genuine wonder of what the fox says, because we didn't know". Although interpreted by some commentators as a reference to the furry fandom, the brothers have stated they did not know about its existence when producing "The Fox".

What is this song Google?

Tap the mic icon and say: “What's this song” or click the “Search a song button.” Then hum for 10 to 15 seconds. On Google Assistant, say “Hey Google, what's this song?” and then hum it. From there, you can listen to the song on a music app, find the lyrics, get information on the song, artist and more.


1 Answers

From the Passing By Reference docs page:

You can pass a variable by reference to a function so the function can modify the variable. The syntax is as follows:

<?php
function foo(&$var)
{
    $var++;
}

$a=5;
foo($a);
// $a is 6 here
?>

...In recent versions of PHP you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);

like image 188
karim79 Avatar answered Sep 23 '22 08:09

karim79