1--TEST-- 2Bug #22231 (segfault when returning a global variable by reference) 3--INI-- 4error_reporting=E_ALL 5--FILE-- 6<?php 7class foo { 8 public $fubar = 'fubar'; 9} 10 11function &foo(){ 12 $obj = new foo(); 13 $GLOBALS['foo'] = &$obj; 14 return $GLOBALS['foo']; 15} 16$bar = &foo(); 17var_dump($bar); 18var_dump($bar->fubar); 19unset($bar); 20$bar = &foo(); 21var_dump($bar->fubar); 22 23$foo = &foo(); 24var_dump($foo); 25var_dump($foo->fubar); 26unset($foo); 27$foo = &foo(); 28var_dump($foo->fubar); 29?> 30--EXPECTF-- 31object(foo)#%d (1) { 32 ["fubar"]=> 33 string(5) "fubar" 34} 35string(5) "fubar" 36string(5) "fubar" 37object(foo)#%d (1) { 38 ["fubar"]=> 39 string(5) "fubar" 40} 41string(5) "fubar" 42string(5) "fubar" 43