1--TEST--
2Test serialize() & unserialize() functions: objects
3--INI--
4serialize_precision=100
5--FILE--
6<?php
7/* Prototype  : proto string serialize(mixed variable)
8 * Description: Returns a string representation of variable (which can later be unserialized)
9 * Source code: ext/standard/var.c
10 * Alias to functions:
11 */
12/* Prototype  : proto mixed unserialize(string variable_representation)
13 * Description: Takes a string representation of variable and recreates it
14 * Source code: ext/standard/var.c
15 * Alias to functions:
16 */
17
18echo "\n--- Testing objects ---\n";
19
20class members
21{
22  private $var_private = 10;
23  protected $var_protected = "string";
24  public $var_public = array(-100.123, "string", TRUE);
25}
26
27$members_obj = new members();
28var_dump( $members_obj );
29$serialize_data = serialize( $members_obj );
30var_dump( $serialize_data );
31$members_obj = unserialize( $serialize_data );
32var_dump( $members_obj );
33
34echo "\n--- testing reference to an obj ---\n";
35$ref_members_obj = &$members_obj;
36$serialize_data = serialize( $ref_members_obj );
37var_dump( $serialize_data );
38$ref_members_obj = unserialize( $serialize_data );
39var_dump( $ref_members_obj );
40
41echo "\nDone";
42?>
43--EXPECTF--
44
45--- Testing objects ---
46object(members)#%d (3) {
47  ["var_private":"members":private]=>
48  int(10)
49  ["var_protected":protected]=>
50  string(6) "string"
51  ["var_public"]=>
52  array(3) {
53    [0]=>
54    float(-100.123)
55    [1]=>
56    string(6) "string"
57    [2]=>
58    bool(true)
59  }
60}
61string(195) "O:7:"members":3:{s:20:"�members�var_private";i:10;s:16:"�*�var_protected";s:6:"string";s:10:"var_public";a:3:{i:0;d:-100.1230000000000046611603465862572193145751953125;i:1;s:6:"string";i:2;b:1;}}"
62object(members)#%d (3) {
63  ["var_private":"members":private]=>
64  int(10)
65  ["var_protected":protected]=>
66  string(6) "string"
67  ["var_public"]=>
68  array(3) {
69    [0]=>
70    float(-100.123)
71    [1]=>
72    string(6) "string"
73    [2]=>
74    bool(true)
75  }
76}
77
78--- testing reference to an obj ---
79string(195) "O:7:"members":3:{s:20:"�members�var_private";i:10;s:16:"�*�var_protected";s:6:"string";s:10:"var_public";a:3:{i:0;d:-100.1230000000000046611603465862572193145751953125;i:1;s:6:"string";i:2;b:1;}}"
80object(members)#%d (3) {
81  ["var_private":"members":private]=>
82  int(10)
83  ["var_protected":protected]=>
84  string(6) "string"
85  ["var_public"]=>
86  array(3) {
87    [0]=>
88    float(-100.123)
89    [1]=>
90    string(6) "string"
91    [2]=>
92    bool(true)
93  }
94}
95
96Done
97