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--- Testing objects ---
45object(members)#%d (3) {
46  ["var_private":"members":private]=>
47  int(10)
48  ["var_protected":protected]=>
49  string(6) "string"
50  ["var_public"]=>
51  array(3) {
52    [0]=>
53    float(-100.123)
54    [1]=>
55    string(6) "string"
56    [2]=>
57    bool(true)
58  }
59}
60string(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;}}"
61object(members)#%d (3) {
62  ["var_private":"members":private]=>
63  int(10)
64  ["var_protected":protected]=>
65  string(6) "string"
66  ["var_public"]=>
67  array(3) {
68    [0]=>
69    float(-100.123)
70    [1]=>
71    string(6) "string"
72    [2]=>
73    bool(true)
74  }
75}
76
77--- testing reference to an obj ---
78string(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;}}"
79object(members)#%d (3) {
80  ["var_private":"members":private]=>
81  int(10)
82  ["var_protected":protected]=>
83  string(6) "string"
84  ["var_public"]=>
85  array(3) {
86    [0]=>
87    float(-100.123)
88    [1]=>
89    string(6) "string"
90    [2]=>
91    bool(true)
92  }
93}
94
95Done
96