1--TEST-- 2Returning a reference from a static method 3--FILE-- 4<?php 5Class C { 6 static function returnConstantByValue() { 7 return 100; 8 } 9 10 static function &returnConstantByRef() { 11 return 100; 12 } 13 14 static function &returnVariableByRef() { 15 return $GLOBALS['a']; 16 } 17} 18 19echo "\n---> 1. Trying to assign by reference the return value of a function that returns by value:\n"; 20unset($a, $b); 21$a = 4; 22$b = &C::returnConstantByValue(); 23$a++; 24var_dump($a, $b); 25 26echo "\n---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:\n"; 27unset($a, $b); 28$a = 4; 29$b = &C::returnConstantByRef(); 30$a++; 31var_dump($a, $b); 32 33echo "\n---> 3. Trying to assign by reference the return value of a function that returns by ref:\n"; 34unset($a, $b); 35$a = 4; 36$b = &C::returnVariableByRef(); 37$a++; 38var_dump($a, $b); 39 40?> 41--EXPECTF-- 42 43---> 1. Trying to assign by reference the return value of a function that returns by value: 44 45Notice: Only variables should be assigned by reference in %s on line 19 46int(5) 47int(100) 48 49---> 2. Trying to assign by reference the return value of a function that returns a constant by ref: 50 51Notice: Only variable references should be returned by reference in %s on line 8 52int(5) 53int(100) 54 55---> 3. Trying to assign by reference the return value of a function that returns by ref: 56int(5) 57int(5) 58