3 /* Functions missing from older PHP versions */
6 /* Added in PHP 4.2.0 */
8 if (!function_exists('floatval')) {
9 function floatval($string) {
10 return ((float) $string);
14 if (!function_exists('is_a')) {
15 function is_a($object, $class) {
16 // by Aidan Lister <aidan@php.net>
17 if (get_class($object) == strtolower($class)) {
20 return is_subclass_of($object, $class);
25 if (!function_exists('ob_clean')) {
27 // by Aidan Lister <aidan@php.net>
28 if (@ob_end_clean()) {
36 /* Added in PHP 4.3.0 */
38 function printr($var, $do_not_echo = false) {
39 // from php.net/print_r user contributed notes
42 $code = htmlentities(ob_get_contents());
45 echo "<pre>$code</pre>";
50 /* compatibility with PHP versions older than 4.3 */
51 if ( !function_exists('file_get_contents') ) {
52 function file_get_contents( $file ) {
54 return !$file ? false : implode('', $file);
58 if (!defined('CASE_LOWER')) {
59 define('CASE_LOWER', 0);
62 if (!defined('CASE_UPPER')) {
63 define('CASE_UPPER', 1);
68 * Replace array_change_key_case()
72 * @link http://php.net/function.array_change_key_case
73 * @author Stephan Schmidt <schst@php.net>
74 * @author Aidan Lister <aidan@php.net>
75 * @version $Revision: 3771 $
77 * @require PHP 4.0.0 (user_error)
79 if (!function_exists('array_change_key_case')) {
80 function array_change_key_case($input, $case = CASE_LOWER)
82 if (!is_array($input)) {
83 user_error('array_change_key_case(): The argument should be an array',
89 $keys = array_keys($input);
90 $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
92 foreach ($keys as $key) {
93 $output[$casefunc($key)] = $input[$key];
101 if(!function_exists('http_build_query')) {
102 function http_build_query( $formdata, $numeric_prefix = null, $key = null ) {
104 foreach ((array)$formdata as $k=>$v) {
105 $tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k);
106 if ($key) $tmp_key = $key.'['.$tmp_key.']';
107 $res[] = ( ( is_array($v) || is_object($v) ) ? http_build_query($v, null, $tmp_key) : $tmp_key."=".urlencode($v) );
109 $separator = ini_get('arg_separator.output');
110 return implode($separator, $res);