1--TEST-- 2"Reference Unpacking - From Functions" list() 3--FILE-- 4<?php 5$arr = [1, 2]; 6function no_ref($a) { 7 return $a; 8} 9 10function no_ref_by_ref(&$a) { 11 return $a; 12} 13 14function &ref_return(&$a) { 15 return $a; 16} 17 18function &ref_return_global() { 19 global $arr; 20 return $arr; 21} 22 23$a = [1, 2]; 24[&$var] = no_ref($a); 25var_dump($var); 26var_dump($a); 27 28$a = [1, 2]; 29[&$var] = no_ref_by_ref($a); 30var_dump($var); 31var_dump($a); 32 33$a = [1, 2]; 34[&$var] = ref_return($a); 35var_dump($var); 36var_dump($a); 37 38[,&$var] = ref_return_global(); 39var_dump($var); 40var_dump($arr); 41?> 42--EXPECTF-- 43Notice: Attempting to set reference to non referenceable value in %s on line %d 44int(1) 45array(2) { 46 [0]=> 47 int(1) 48 [1]=> 49 int(2) 50} 51 52Notice: Attempting to set reference to non referenceable value in %s on line %d 53int(1) 54array(2) { 55 [0]=> 56 int(1) 57 [1]=> 58 int(2) 59} 60int(1) 61array(2) { 62 [0]=> 63 &int(1) 64 [1]=> 65 int(2) 66} 67int(2) 68array(2) { 69 [0]=> 70 int(1) 71 [1]=> 72 &int(2) 73} 74