Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
header('Content-Type: application/xhtml+xml; charset=utf-8');
3
header('Vary: Accept');
4
?>
5
<?xml version="1.0" encoding="UTF-8"?>
6
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
7
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
8
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
9
<head>
10
	<title>An XHTML 1.0 Strict standard template</title>
11
	<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
12
	<meta http-equiv="Content-Style-Type" content="text/css" />
13
</head>
14
<body>
15
 
16
<?php
17
 
18
include_once 'Var_Dump.php';
19
 
20
echo '<h1>example3.php : factory approach</h1>';
21
 
22
/*
23
 * example3.php : Factory approach
24
 *
25
 * If you want to use a factory object, you will have to instanciate an
26
 * object with the appropriate parameters, and then to use the "toString"
27
 * method, as the display method is inacurate in this case.
28
 *
29
 */
30
 
31
// Initialise the HTML4 Table rendering (see Var_Dump/Renderer/HTML4_Table.php)
32
$myVarDump = & Var_Dump::factory(
33
    array(
34
        'display_mode' => 'HTML4_Table'
35
    ),
36
    array(
37
        'show_caption'   => FALSE,
38
        'bordercolor'    => '#DDDDDD',
39
        'bordersize'     => '2',
40
        'captioncolor'   => 'white',
41
        'cellpadding'    => '4',
42
        'cellspacing'    => '0',
43
        'color1'         => '#FFFFFF',
44
        'color2'         => '#F4F4F4',
45
        'before_num_key' => '<font color="#CC5450"><b>',
46
        'after_num_key'  => '</b></font>',
47
        'before_str_key' => '<font color="#5450CC">',
48
        'after_str_key'  => '</font>',
49
        'before_value'   => '<i>',
50
        'after_value'    => '</i>'
51
    )
52
);
53
 
54
/*
55
 * Displays an array
56
 */
57
 
58
echo '<h2>Array</h2>';
59
 
60
$fileHandler = tmpfile();
61
$linkedArray = array('John', 'Jack', 'Bill');
62
$array = array(
63
    'key-1' => 'The quick brown fox jumped over the lazy dog',
64
    'key-2' => 234,
65
    'key-3' => array(
66
        'key-3-1' => 31.789,
67
        'key-3-2' => & $linkedArray,
68
        'file'    => $fileHandler
69
    ),
70
    'key-4' => NULL
71
);
72
echo $myVarDump->toString($array);
73
 
74
/*
75
 * Displays an object (with recursion)
76
 */
77
 
78
echo '<h2>Object (Recursive)</h2>';
79
 
80
class c_parent {
81
    function c_parent() {
82
        $this->myChild = new child($this);
83
        $this->myName = 'c_parent';
84
    }
85
}
86
class child {
87
    function child(& $c_parent) {
88
        $this->myParent = & $c_parent;
89
    }
90
}
91
$recursiveObject = new c_parent();
92
echo $myVarDump->toString($recursiveObject);
93
 
94
/*
95
 * Displays a classic object
96
 */
97
 
98
echo '<h2>Object (Classic)</h2>';
99
 
100
class test {
101
    var $foo = 0;
102
    var $bar = '';
103
    function get_foo() {
104
        return $this->foo;
105
    }
106
    function get_bar() {
107
        return $this->bar;
108
    }
109
}
110
$object = new test();
111
$object->foo = 753;
112
$object->bar = '357';
113
echo $myVarDump->toString($object);
114
 
115
/*
116
 * Displays a variable using the display() method
117
 */
118
 
119
echo '<h2>Var_Dump::display()</h2>';
120
echo '<p>Singleton method, uses the default configuration parameters for the rendering, because we are not using the previously instanciated object</p>';
121
 
122
Var_Dump::display($array);
123
 
124
fclose($fileHandler);
125
 
126
?>
127
 
128
</body>
129
</html>