1--TEST--
2Test serialize() & unserialize() functions: objects (abstract classes)
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 Abstract Class ---\n";
19// abstract class
20abstract class Name
21{
22  public function __construct() {
23    $this->a = 10;
24    $this->b = 12.222;
25    $this->c = "string";
26  }
27  abstract protected function getClassName();
28  public function printClassName () {
29    return $this->getClassName();
30  }
31}
32// implement abstract class
33class extendName extends Name
34{
35  var $a, $b, $c;
36
37  protected function getClassName() {
38    return "extendName";
39  }
40}
41
42$obj_extendName = new extendName();
43$serialize_data = serialize($obj_extendName);
44var_dump( $serialize_data );
45$unserialize_data = unserialize($serialize_data);
46var_dump( $unserialize_data );
47
48$serialize_data = serialize($obj_extendName->printClassName());
49var_dump( $serialize_data );
50$unserialize_data = unserialize($serialize_data);
51var_dump( $unserialize_data );
52
53echo "\nDone";
54?>
55--EXPECTF--
56--- Testing Abstract Class ---
57string(119) "O:10:"extendName":3:{s:1:"a";i:10;s:1:"b";d:12.2219999999999995310417943983338773250579833984375;s:1:"c";s:6:"string";}"
58object(extendName)#%d (3) {
59  ["a"]=>
60  int(10)
61  ["b"]=>
62  float(12.222)
63  ["c"]=>
64  string(6) "string"
65}
66string(18) "s:10:"extendName";"
67string(10) "extendName"
68
69Done
70