Only named variables may be assigned by reference. : Variable Reference « Language Basics « PHP






Only named variables may be assigned by reference.

 
<?php
    $foo = 25;
    $bar = &$foo; // This is a valid assignment.
    
    function test() {
        return 25;
    }
    $bar = &test(); // Invalid.
?>
  
  








Related examples in the same category

1.$b is assigned a copy of $a, and in the second part, $b is assigned a reference to $a.
2.& operator creates a reference
3.Create a reference to a variable with the name of the constant's value.
4.Passing by Reference in PHP
5.Passing arrays by reference