1--TEST--
2Test serialize() & unserialize() functions: objects - ensure that COW references of objects are not serialized separately (unlike other types).
3--FILE--
4<?php
5/* Prototype  : proto string serialize(mixed variable)
6 * Description: Returns a string representation of variable (which can later be unserialized)
7 * Source code: ext/standard/var.c
8 * Alias to functions:
9 */
10/* Prototype  : proto mixed unserialize(string variable_representation)
11 * Description: Takes a string representation of variable and recreates it
12 * Source code: ext/standard/var.c
13 * Alias to functions:
14 */
15
16$x = new stdClass;
17$ref = &$x;
18var_dump(serialize(array($x, $x)));
19
20$x = 1;
21$ref = &$x;
22var_dump(serialize(array($x, $x)));
23
24$x = "a";
25$ref = &$x;
26var_dump(serialize(array($x, $x)));
27
28$x = true;
29$ref = &$x;
30var_dump(serialize(array($x, $x)));
31
32$x = null;
33$ref = &$x;
34var_dump(serialize(array($x, $x)));
35
36$x = array();
37$ref = &$x;
38var_dump(serialize(array($x, $x)));
39
40echo "Done";
41?>
42--EXPECTF--
43string(37) "a:2:{i:0;O:8:"stdClass":0:{}i:1;r:2;}"
44string(22) "a:2:{i:0;i:1;i:1;i:1;}"
45string(30) "a:2:{i:0;s:1:"a";i:1;s:1:"a";}"
46string(22) "a:2:{i:0;b:1;i:1;b:1;}"
47string(18) "a:2:{i:0;N;i:1;N;}"
48string(26) "a:2:{i:0;a:0:{}i:1;a:0:{}}"
49Done