Changeset 6672
- Timestamp:
- 01/28/2008 08:15:20 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/compat.php
r6485 r6672 7 7 */ 8 8 9 /* Added in PHP 4.2.0 */ 10 11 if (!function_exists('floatval')) { 12 function floatval($string) { 13 return ((float) $string); 14 } 15 } 16 17 if (!function_exists('is_a')) { 18 function is_a($object, $class) { 19 // by Aidan Lister <aidan@php.net> 20 if (get_class($object) == strtolower($class)) { 21 return true; 22 } else { 23 return is_subclass_of($object, $class); 24 } 25 } 26 } 27 28 if (!function_exists('ob_clean')) { 29 function ob_clean() { 30 // by Aidan Lister <aidan@php.net> 31 if (@ob_end_clean()) { 32 return ob_start(); 33 } 34 return false; 35 } 36 } 37 38 39 /* Added in PHP 4.3.0 */ 40 41 function printr($var, $do_not_echo = false) { 42 // from php.net/print_r user contributed notes 43 ob_start(); 44 print_r($var); 45 $code = htmlentities(ob_get_contents()); 46 ob_clean(); 47 if (!$do_not_echo) { 48 echo "<pre>$code</pre>"; 49 } 50 ob_end_clean(); 51 return $code; 52 } 53 54 /* compatibility with PHP versions older than 4.3 */ 55 if ( !function_exists('file_get_contents') ) { 56 function file_get_contents( $file ) { 57 $file = file($file); 58 return !$file ? false : implode('', $file); 59 } 60 } 61 62 if (!defined('CASE_LOWER')) { 63 define('CASE_LOWER', 0); 64 } 65 66 if (!defined('CASE_UPPER')) { 67 define('CASE_UPPER', 1); 68 } 69 70 71 /** 72 * Replace array_change_key_case() 73 * 74 * @category PHP 75 * @package PHP_Compat 76 * @link http://php.net/function.array_change_key_case 77 * @author Stephan Schmidt <schst@php.net> 78 * @author Aidan Lister <aidan@php.net> 79 * @version $Revision$ 80 * @since PHP 4.2.0 81 * @require PHP 4.0.0 (user_error) 82 */ 83 if (!function_exists('array_change_key_case')) { 84 function array_change_key_case($input, $case = CASE_LOWER) 85 { 86 if (!is_array($input)) { 87 user_error('array_change_key_case(): The argument should be an array', 88 E_USER_WARNING); 89 return false; 90 } 91 92 $output = array (); 93 $keys = array_keys($input); 94 $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; 95 96 foreach ($keys as $key) { 97 $output[$casefunc($key)] = $input[$key]; 98 } 99 100 return $output; 101 } 102 } 9 // Added in PHP 5.0 103 10 104 11 if (!function_exists('http_build_query')) { … … 144 51 } 145 52 146 // Added in PHP 5.0147 53 if (!function_exists('stripos')) { 148 54 function stripos($haystack, $needle, $offset = 0) { … … 172 78 endif; 173 79 174 // Added in PHP 4.3.0?175 if (!defined('IMAGETYPE_GIF'))176 define('IMAGETYPE_GIF', 1);177 178 if (!defined('IMAGETYPE_JPEG'))179 define('IMAGETYPE_JPEG', 2);180 181 if (!defined('IMAGETYPE_PNG'))182 define('IMAGETYPE_PNG', 3);183 184 if (!defined('IMAGETYPE_TIFF_MM'))185 define('IMAGETYPE_TIFF_MM',7);186 187 if (!defined('IMAGETYPE_TIFF_MM'))188 define('IMAGETYPE_TIFF_MM',8);189 190 80 ?>
Note: See TracChangeset
for help on using the changeset viewer.