In this example you are simply creating an array array(&$this, 'adminInit')
where array[0]
now references whatever $this
is, and array[1] = 'adminInit'
.
I believe in this case $this
references the class you’re in ( denoted by &$this ) and then adminInit
is likely a function (method) within that class.
Therefore when the admin_init
happens it knows to access the adminInit()
function in the current class you’re in.
& preceding a variable means it’s a reference (pointer) to this variable and not the actual value. Of course it will still return the value when called but it does it sort of like a shortcut would to open file. Here’s an example to help you understand.
$variable1 = "one"; //set $variable1
$variable2 = &$variable1; //make $variable2 reference $variable1
echo $variable1; //echos "one"
echo "<br>";
echo $variable2; //echos "one"
echo "<hr>";
$variable1 = "two"; //only change the value of $variable1
echo $variable1; //echos "two"
echo "<br>";
echo $variable2; //echos "two"
echo "<hr>";
$variable2 = "three"; //only change the value of $variable2 (which is actually $variable1 by reference)
echo $variable1; //echos "three"
echo "<br>";
echo $variable2; //echos "three"
echo "<hr>";
Another way to understand it would be like…
function change_reference( &$ref ){
$ref = "two";
}
$var1 = "one";
change_reference( $var1 );
echo $var1; //will echo "two"
You can start here http://php.net/manual/en/language.references.whatare.php and then use the References Explained menu links to dig deeper.