xref: /PHP-7.2/ext/session/tests/019.phpt (revision f1d7e3ca)
1--TEST--
2serializing references test case using globals
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
13
14error_reporting(E_ALL);
15
16class TFoo {
17	public $c;
18	function __construct($c) {
19		$this->c = $c;
20	}
21	function inc() {
22		$this->c++;
23	}
24}
25
26session_id("abtest");
27session_start();
28
29$_SESSION["o1"] = new TFoo(42);
30$_SESSION["o2"] =& $_SESSION["o1"];
31
32session_write_close();
33
34unset($_SESSION["o1"]);
35unset($_SESSION["o2"]);
36
37session_start();
38
39var_dump($_SESSION);
40
41$_SESSION["o1"]->inc();
42$_SESSION["o2"]->inc();
43
44var_dump($_SESSION);
45
46session_destroy();
47?>
48--EXPECTF--
49array(2) {
50  ["o1"]=>
51  &object(TFoo)#%d (1) {
52    ["c"]=>
53    int(42)
54  }
55  ["o2"]=>
56  &object(TFoo)#%d (1) {
57    ["c"]=>
58    int(42)
59  }
60}
61array(2) {
62  ["o1"]=>
63  &object(TFoo)#%d (1) {
64    ["c"]=>
65    int(44)
66  }
67  ["o2"]=>
68  &object(TFoo)#%d (1) {
69    ["c"]=>
70    int(44)
71  }
72}
73