diff options
Diffstat (limited to 'includes/xmlrpc/var_export.php')
-rw-r--r-- | includes/xmlrpc/var_export.php | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/includes/xmlrpc/var_export.php b/includes/xmlrpc/var_export.php new file mode 100644 index 0000000..3a5ac3f --- /dev/null +++ b/includes/xmlrpc/var_export.php | |||
@@ -0,0 +1,105 @@ | |||
1 | <?php | ||
2 | // +----------------------------------------------------------------------+ | ||
3 | // | PHP Version 4 | | ||
4 | // +----------------------------------------------------------------------+ | ||
5 | // | Copyright (c) 1997-2004 The PHP Group | | ||
6 | // +----------------------------------------------------------------------+ | ||
7 | // | This source file is subject to version 3.0 of the PHP license, | | ||
8 | // | that is bundled with this package in the file LICENSE, and is | | ||
9 | // | available at through the world-wide-web at | | ||
10 | // | http://www.php.net/license/3_0.txt. | | ||
11 | // | If you did not receive a copy of the PHP license and are unable to | | ||
12 | // | obtain it through the world-wide-web, please send a note to | | ||
13 | // | license@php.net so we can mail you a copy immediately. | | ||
14 | // +----------------------------------------------------------------------+ | ||
15 | // | Authors: Aidan Lister <aidan@php.net> | | ||
16 | // +----------------------------------------------------------------------+ | ||
17 | // | ||
18 | // $Id: var_export.php,v 1.2 2005/11/21 10:57:23 ggiunta Exp $ | ||
19 | |||
20 | |||
21 | /** | ||
22 | * Replace var_export() | ||
23 | * | ||
24 | * @category PHP | ||
25 | * @package PHP_Compat | ||
26 | * @link http://php.net/function.var_export | ||
27 | * @author Aidan Lister <aidan@php.net> | ||
28 | * @version $Revision: 1.2 $ | ||
29 | * @since PHP 4.2.0 | ||
30 | * @require PHP 4.0.0 (user_error) | ||
31 | */ | ||
32 | if (!function_exists('var_export')) { | ||
33 | function var_export($array, $return = false, $lvl=0) | ||
34 | { | ||
35 | // Common output variables | ||
36 | $indent = ' '; | ||
37 | $doublearrow = ' => '; | ||
38 | $lineend = ",\n"; | ||
39 | $stringdelim = '\''; | ||
40 | |||
41 | // Check the export isn't a simple string / int | ||
42 | if (is_string($array)) { | ||
43 | $out = $stringdelim . str_replace('\'', '\\\'', str_replace('\\', '\\\\', $array)) . $stringdelim; | ||
44 | } elseif (is_int($array) || is_float($array)) { | ||
45 | $out = (string)$array; | ||
46 | } elseif (is_bool($array)) { | ||
47 | $out = $array ? 'true' : 'false'; | ||
48 | } elseif (is_null($array)) { | ||
49 | $out = 'NULL'; | ||
50 | } elseif (is_resource($array)) { | ||
51 | $out = 'resource'; | ||
52 | } else { | ||
53 | // Begin the array export | ||
54 | // Start the string | ||
55 | $out = "array (\n"; | ||
56 | |||
57 | // Loop through each value in array | ||
58 | foreach ($array as $key => $value) { | ||
59 | // If the key is a string, delimit it | ||
60 | if (is_string($key)) { | ||
61 | $key = str_replace('\'', '\\\'', str_replace('\\', '\\\\', $key)); | ||
62 | $key = $stringdelim . $key . $stringdelim; | ||
63 | } | ||
64 | |||
65 | $val = var_export($value, true, $lvl+1); | ||
66 | // Delimit value | ||
67 | /*if (is_array($value)) { | ||
68 | // We have an array, so do some recursion | ||
69 | // Do some basic recursion while increasing the indent | ||
70 | $recur_array = explode($newline, var_export($value, true)); | ||
71 | $temp_array = array(); | ||
72 | foreach ($recur_array as $recur_line) { | ||
73 | $temp_array[] = $indent . $recur_line; | ||
74 | } | ||
75 | $recur_array = implode($newline, $temp_array); | ||
76 | $value = $newline . $recur_array; | ||
77 | } elseif (is_null($value)) { | ||
78 | $value = 'NULL'; | ||
79 | } else { | ||
80 | $value = str_replace($find, $replace, $value); | ||
81 | $value = $stringdelim . $value . $stringdelim; | ||
82 | }*/ | ||
83 | |||
84 | // Piece together the line | ||
85 | for ($i = 0; $i < $lvl; $i++) | ||
86 | $out .= $indent; | ||
87 | $out .= $key . $doublearrow . $val . $lineend; | ||
88 | } | ||
89 | |||
90 | // End our string | ||
91 | for ($i = 0; $i < $lvl; $i++) | ||
92 | $out .= $indent; | ||
93 | $out .= ")"; | ||
94 | } | ||
95 | |||
96 | // Decide method of output | ||
97 | if ($return === true) { | ||
98 | return $out; | ||
99 | } else { | ||
100 | echo $out; | ||
101 | return; | ||
102 | } | ||
103 | } | ||
104 | } | ||
105 | ?> \ No newline at end of file | ||