1--TEST-- 2Test serialize() & unserialize() functions: objects 3--INI-- 4serialize_precision=100 5--FILE-- 6<?php 7echo "\n--- Testing objects ---\n"; 8 9class members 10{ 11 private $var_private = 10; 12 protected $var_protected = "string"; 13 public $var_public = array(-100.123, "string", TRUE); 14} 15 16$members_obj = new members(); 17var_dump( $members_obj ); 18$serialize_data = serialize( $members_obj ); 19var_dump( $serialize_data ); 20$members_obj = unserialize( $serialize_data ); 21var_dump( $members_obj ); 22 23echo "\n--- testing reference to an obj ---\n"; 24$ref_members_obj = &$members_obj; 25$serialize_data = serialize( $ref_members_obj ); 26var_dump( $serialize_data ); 27$ref_members_obj = unserialize( $serialize_data ); 28var_dump( $ref_members_obj ); 29 30echo "\nDone"; 31?> 32--EXPECTF-- 33--- Testing objects --- 34object(members)#%d (3) { 35 ["var_private":"members":private]=> 36 int(10) 37 ["var_protected":protected]=> 38 string(6) "string" 39 ["var_public"]=> 40 array(3) { 41 [0]=> 42 float(-100.1230000000000046611603465862572193145751953125) 43 [1]=> 44 string(6) "string" 45 [2]=> 46 bool(true) 47 } 48} 49string(195) "O:7:"members":3:{s:20:"%0members%0var_private";i:10;s:16:"%0*%0var_protected";s:6:"string";s:10:"var_public";a:3:{i:0;d:-100.1230000000000046611603465862572193145751953125;i:1;s:6:"string";i:2;b:1;}}" 50object(members)#%d (3) { 51 ["var_private":"members":private]=> 52 int(10) 53 ["var_protected":protected]=> 54 string(6) "string" 55 ["var_public"]=> 56 array(3) { 57 [0]=> 58 float(-100.1230000000000046611603465862572193145751953125) 59 [1]=> 60 string(6) "string" 61 [2]=> 62 bool(true) 63 } 64} 65 66--- testing reference to an obj --- 67string(195) "O:7:"members":3:{s:20:"%0members%0var_private";i:10;s:16:"%0*%0var_protected";s:6:"string";s:10:"var_public";a:3:{i:0;d:-100.1230000000000046611603465862572193145751953125;i:1;s:6:"string";i:2;b:1;}}" 68object(members)#%d (3) { 69 ["var_private":"members":private]=> 70 int(10) 71 ["var_protected":protected]=> 72 string(6) "string" 73 ["var_public"]=> 74 array(3) { 75 [0]=> 76 float(-100.1230000000000046611603465862572193145751953125) 77 [1]=> 78 string(6) "string" 79 [2]=> 80 bool(true) 81 } 82} 83 84Done 85