xref: /PHP-5.3/ext/session/tests/026.phpt (revision 57e0d2ac)
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;
36
37session_write_close();
38unset($_SESSION['a']);
39unset($_SESSION['b']);
40
41session_start();
42$a = $_SESSION['a'];
43$b = $_SESSION['b'];
44echo "values after session:\n";
45var_dump($a,$b);
46?>
47--EXPECTF--
48original values:
49object(a)#%d (1) {
50  ["test"]=>
51  string(5) "hallo"
52}
53object(b)#%d (1) {
54  ["a"]=>
55  &object(a)#%d (1) {
56    ["test"]=>
57    string(5) "hallo"
58  }
59}
60values after session:
61object(a)#%d (1) {
62  ["test"]=>
63  string(5) "hallo"
64}
65object(b)#%d (1) {
66  ["a"]=>
67  &object(a)#%d (1) {
68    ["test"]=>
69    string(5) "hallo"
70  }
71}
72