blob: d72c471fae3e51a0b2642dace5e620eb86a3474b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
--TEST--
Test serialize() & unserialize() functions: objects (abstract classes)
--INI--
serialize_precision=100
--FILE--
<?php
/* Prototype : proto string serialize(mixed variable)
* Description: Returns a string representation of variable (which can later be unserialized)
* Source code: ext/standard/var.c
* Alias to functions:
*/
/* Prototype : proto mixed unserialize(string variable_representation)
* Description: Takes a string representation of variable and recreates it
* Source code: ext/standard/var.c
* Alias to functions:
*/
echo "\n--- Testing Abstract Class ---\n";
// abstract class
abstract class Name
{
public function __construct() {
$this->a = 10;
$this->b = 12.222;
$this->c = "string";
}
abstract protected function getClassName();
public function printClassName () {
return $this->getClassName();
}
}
// implement abstract class
class extendName extends Name
{
var $a, $b, $c;
protected function getClassName() {
return "extendName";
}
}
$obj_extendName = new extendName();
$serialize_data = serialize($obj_extendName);
var_dump( $serialize_data );
$unserialize_data = unserialize($serialize_data);
var_dump( $unserialize_data );
$serialize_data = serialize($obj_extendName->printClassName());
var_dump( $serialize_data );
$unserialize_data = unserialize($serialize_data);
var_dump( $unserialize_data );
echo "\nDone";
?>
--EXPECTF--
--- Testing Abstract Class ---
string(119) "O:10:"extendName":3:{s:1:"a";i:10;s:1:"b";d:12.2219999999999995310417943983338773250579833984375;s:1:"c";s:6:"string";}"
object(extendName)#%d (3) {
["a"]=>
int(10)
["b"]=>
float(12.222)
["c"]=>
string(6) "string"
}
string(18) "s:10:"extendName";"
string(10) "extendName"
Done
|