May 2016
Intermediate to advanced
155 pages
2h 15m
English
© Mikael Olsson 2016
Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_27
Mikael Olsson1
(1)Hammarland, Finland
A reference is an alias that allows two different variables to write to the same value. There are three operations that can be performed with references: assign by reference, pass by reference, and return by reference.
A reference is assigned by placing an ampersand (&) before the variable that is to be bound.
$x = 5;$r = &$x; // r is a reference to x$s =& $x; // alternative syntax
The reference then becomes an alias for that variable and can be used exactly as if it was the original variable.
$r = 10; // assign value to $r/$xecho $x; // "10"
In PHP, function arguments ...
Read now
Unlock full access