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