diff --git a/language/references.xml b/language/references.xml index 76a1210bfc87..7eafdfacfcdb 100644 --- a/language/references.xml +++ b/language/references.xml @@ -490,12 +490,26 @@ function &collector() } $collection = &collector(); +// Now the $collection is a referenced variable that references the static array inside the function + $collection[] = 'foo'; +print_r(collector()); +// Array +// ( +// [0] => foo +// ) + ?> ]]> + + + If the assignment is done without the & symbol, e.g. $collection = collector();, + the $collection variable will receive a copy of the value, not the reference returned by the function. + + To pass the returned reference to another function expecting a reference you can use this syntax: