Annotation of embedaddon/php/ext/standard/tests/serialize/serialization_objects_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test serialize() & unserialize() functions: objects
3: --INI--
4: serialize_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:
18: echo "\n--- Testing objects ---\n";
19:
20: class 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();
28: var_dump( $members_obj );
29: $serialize_data = serialize( $members_obj );
30: var_dump( $serialize_data );
31: $members_obj = unserialize( $serialize_data );
32: var_dump( $members_obj );
33:
34: echo "\n--- testing reference to an obj ---\n";
35: $ref_members_obj = &$members_obj;
36: $serialize_data = serialize( $ref_members_obj );
37: var_dump( $serialize_data );
38: $ref_members_obj = unserialize( $serialize_data );
39: var_dump( $ref_members_obj );
40:
41: echo "\nDone";
42: ?>
43: --EXPECTF--
44:
45: --- Testing objects ---
46: object(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: }
61: string(195) "O:7:"members":3:{s:20:"