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