xref: /PHP-5.4/ext/session/tests/006.phpt (revision 8deefa87)
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=
8session.serialize_handler=php
9session.save_handler=files
10--FILE--
11<?php
12error_reporting(E_ALL);
13
14session_id("abtest");
15session_start();
16
17class a {
18    public $test = "hallo";
19}
20
21class b {
22    public $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
34$_SESSION["a"] = $a;
35$_SESSION["b"] = $b;
36session_write_close();
37
38unset($_SESSION["a"], $_SESSION["b"]);
39
40session_start();
41
42echo "values after session:\n";
43var_dump($a,$b);
44?>
45--EXPECTF--
46original values:
47object(a)#%d (1) {
48  ["test"]=>
49  string(5) "hallo"
50}
51object(b)#%d (1) {
52  ["a"]=>
53  &object(a)#%d (1) {
54    ["test"]=>
55    string(5) "hallo"
56  }
57}
58values after session:
59object(a)#%d (1) {
60  ["test"]=>
61  string(5) "hallo"
62}
63object(b)#%d (1) {
64  ["a"]=>
65  &object(a)#%d (1) {
66    ["test"]=>
67    string(5) "hallo"
68  }
69}
70