xref: /PHP-8.3/ext/session/tests/019.phpt (revision b5a14e6c)
1--TEST--
2serializing references test case using globals
3--EXTENSIONS--
4session
5--SKIPIF--
6<?php include('skipif.inc'); ?>
7--INI--
8session.use_cookies=0
9session.use_strict_mode=0
10session.cache_limiter=
11session.serialize_handler=php
12session.save_handler=files
13--FILE--
14<?php
15
16error_reporting(E_ALL);
17
18class TFoo {
19    public $c;
20    function __construct($c) {
21        $this->c = $c;
22    }
23    function inc() {
24        $this->c++;
25    }
26}
27
28session_id("test019");
29session_start();
30
31$_SESSION["o1"] = new TFoo(42);
32$_SESSION["o2"] =& $_SESSION["o1"];
33
34session_write_close();
35
36unset($_SESSION["o1"]);
37unset($_SESSION["o2"]);
38
39session_start();
40
41var_dump($_SESSION);
42
43$_SESSION["o1"]->inc();
44$_SESSION["o2"]->inc();
45
46var_dump($_SESSION);
47
48session_destroy();
49?>
50--EXPECTF--
51array(2) {
52  ["o1"]=>
53  &object(TFoo)#%d (1) {
54    ["c"]=>
55    int(42)
56  }
57  ["o2"]=>
58  &object(TFoo)#%d (1) {
59    ["c"]=>
60    int(42)
61  }
62}
63array(2) {
64  ["o1"]=>
65  &object(TFoo)#%d (1) {
66    ["c"]=>
67    int(44)
68  }
69  ["o2"]=>
70  &object(TFoo)#%d (1) {
71    ["c"]=>
72    int(44)
73  }
74}
75