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---> 1. Trying to assign by reference the return value of a function that returns by value: 43 44Notice: Only variables should be assigned by reference in %s on line 19 45int(5) 46int(100) 47 48---> 2. Trying to assign by reference the return value of a function that returns a constant by ref: 49 50Notice: Only variable references should be returned by reference in %s on line 8 51int(5) 52int(100) 53 54---> 3. Trying to assign by reference the return value of a function that returns by ref: 55int(5) 56int(5) 57