mirror of
https://github.com/php/php-src.git
synced 2024-12-04 07:14:10 +08:00
40 lines
629 B
PHP
40 lines
629 B
PHP
--TEST--
|
|
Bug #22231 (segfault when returning a global variable by reference)
|
|
--FILE--
|
|
<?php
|
|
class foo {
|
|
public $fubar = 'fubar';
|
|
}
|
|
|
|
function &foo(){
|
|
$GLOBALS['foo'] = &new foo();
|
|
return $GLOBALS['foo'];
|
|
}
|
|
$bar = &foo();
|
|
var_dump($bar);
|
|
var_dump($bar->fubar);
|
|
unset($bar);
|
|
$bar = &foo();
|
|
var_dump($bar->fubar);
|
|
|
|
$foo = &foo();
|
|
var_dump($foo);
|
|
var_dump($foo->fubar);
|
|
unset($foo);
|
|
$foo = &foo();
|
|
var_dump($foo->fubar);
|
|
?>
|
|
--EXPECTF--
|
|
object(foo)#%d (1) {
|
|
["fubar"]=>
|
|
string(5) "fubar"
|
|
}
|
|
string(5) "fubar"
|
|
string(5) "fubar"
|
|
object(foo)#%d (1) {
|
|
["fubar"]=>
|
|
string(5) "fubar"
|
|
}
|
|
string(5) "fubar"
|
|
string(5) "fubar"
|