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>";
51 /* compatibility with PHP versions older than 4.3 */
52 if ( !function_exists('file_get_contents') ) {
53 function file_get_contents( $file ) {
55 return !$file ? false : implode('', $file);
59 if (!defined('CASE_LOWER')) {
60 define('CASE_LOWER', 0);
63 if (!defined('CASE_UPPER')) {
64 define('CASE_UPPER', 1);
69 * Replace array_change_key_case()
73 * @link http://php.net/function.array_change_key_case
74 * @author Stephan Schmidt <schst@php.net>
75 * @author Aidan Lister <aidan@php.net>
76 * @version $Revision: 6070 $
78 * @require PHP 4.0.0 (user_error)
80 if (!function_exists('array_change_key_case')) {
81 function array_change_key_case($input, $case = CASE_LOWER)
83 if (!is_array($input)) {
84 user_error('array_change_key_case(): The argument should be an array',
90 $keys = array_keys($input);
91 $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
93 foreach ($keys as $key) {
94 $output[$casefunc($key)] = $input[$key];
101 if (!function_exists('http_build_query')) {
102 function http_build_query($data, $prefix=null, $sep=null) {
103 return _http_build_query($data, $prefix, $sep);
107 // from php.net (modified by Mark Jaquith to behave like the native PHP5 function)
108 function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) {
111 foreach ( (array) $data as $k => $v ) {
114 if ( is_int($k) && $prefix != null )
117 $k = $key . '%5B' . $k . '%5D';
120 elseif ( $v === FALSE )
123 if ( is_array($v) || is_object($v) )
124 array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode));
125 elseif ( $urlencode )
126 array_push($ret, $k.'='.urlencode($v));
128 array_push($ret, $k.'='.$v);
132 $sep = ini_get('arg_separator.output');
134 return implode($sep, $ret);
137 if ( !function_exists('_') ) {
138 function _($string) {
144 if (!function_exists('stripos')) {
145 function stripos($haystack, $needle, $offset = 0) {
146 return strpos(strtolower($haystack), strtolower($needle), $offset);