xref: /PHP-7.4/ext/session/tests/006.phpt (revision 114c544b)
1--TEST--
2References between variables in sessions
3--SKIPIF--
4<?php include('skipif.inc'); ?>
5--INI--
6register_globals=1
7--FILE--
8<?php
9error_reporting(E_ALL & ~E_NOTICE);
10
11ob_start();
12session_id("abtest");
13session_start();
14
15class a {
16    var $test = "hallo";
17}
18
19class b {
20    var $a;
21    function b(&$a) {
22        $this->a = &$a;
23    }
24}
25
26$a = new a();
27$b = new b($a);
28
29echo "original values:\n";
30var_dump($a,$b);
31
32session_register("a");
33session_register("b");
34session_write_close();
35
36session_unregister("a");
37session_unregister("b");
38
39session_start();
40
41echo "values after session:\n";
42var_dump($a,$b);
43?>
44--EXPECT--
45original values:
46object(a)(1) {
47  ["test"]=>
48  string(5) "hallo"
49}
50object(b)(1) {
51  ["a"]=>
52  &object(a)(1) {
53    ["test"]=>
54    string(5) "hallo"
55  }
56}
57values after session:
58object(a)(1) {
59  ["test"]=>
60  string(5) "hallo"
61}
62object(b)(1) {
63  ["a"]=>
64  &object(a)(1) {
65    ["test"]=>
66    string(5) "hallo"
67  }
68}
69