home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-includes / functions-compat.php < prev    next >
Encoding:
PHP Script  |  2005-02-11  |  1.9 KB  |  92 lines

  1. <?php
  2.  
  3. /* Functions missing from older PHP versions */
  4.  
  5.  
  6. /* Added in PHP 4.2.0 */
  7.  
  8. if (!function_exists('floatval')) {
  9.     function floatval($string) {
  10.         return ((float) $string);
  11.     }
  12. }
  13.  
  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)) {
  18.             return true;
  19.         } else {
  20.             return is_subclass_of($object, $class);
  21.         }
  22.     }
  23. }
  24.  
  25. if (!function_exists('ob_clean')) {
  26.     function ob_clean() {
  27.         // by Aidan Lister <aidan@php.net>
  28.         if (@ob_end_clean()) {
  29.             return ob_start();
  30.         }
  31.         return false;
  32.     }
  33. }
  34.  
  35.  
  36. /* Added in PHP 4.3.0 */
  37.  
  38. function printr($var, $do_not_echo = false) {
  39.     // from php.net/print_r user contributed notes 
  40.     ob_start();
  41.     print_r($var);
  42.     $code =  htmlentities(ob_get_contents());
  43.     ob_clean();
  44.     if (!$do_not_echo) {
  45.       echo "<pre>$code</pre>";
  46.     }
  47.     return $code;
  48. }
  49.  
  50. if (!defined('CASE_LOWER')) {
  51.     define('CASE_LOWER', 0);
  52. }
  53.  
  54. if (!defined('CASE_UPPER')) {
  55.     define('CASE_UPPER', 1);
  56. }
  57.  
  58.  
  59. /**
  60.  * Replace array_change_key_case()
  61.  *
  62.  * @category    PHP
  63.  * @package     PHP_Compat
  64.  * @link        http://php.net/function.array_change_key_case
  65.  * @author      Stephan Schmidt <schst@php.net>
  66.  * @author      Aidan Lister <aidan@php.net>
  67.  * @version     $Revision: 2247 $
  68.  * @since       PHP 4.2.0
  69.  * @require     PHP 4.0.0 (user_error)
  70.  */
  71. if (!function_exists('array_change_key_case')) {
  72.     function array_change_key_case($input, $case = CASE_LOWER)
  73.     {
  74.         if (!is_array($input)) {
  75.             user_error('array_change_key_case(): The argument should be an array',
  76.                 E_USER_WARNING);
  77.             return false;
  78.         }
  79.  
  80.         $output   = array ();
  81.         $keys     = array_keys($input);
  82.         $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
  83.  
  84.         foreach ($keys as $key) {
  85.             $output[$casefunc($key)] = $input[$key];
  86.         }
  87.  
  88.         return $output;
  89.     }
  90. }
  91.  
  92. ?>