PHP_Compat
[ class tree: PHP_Compat ] [ index: PHP_Compat ] [ all elements ]

Source for file Compat.php

Documentation is available at Compat.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2004 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Aidan Lister <aidan@php.net>                                |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Compat.php,v 1.11 2004/05/29 04:16:15 aidan Exp $
  20. //
  21.  
  22.  
  23. /**
  24.  * Provides missing functionality in the form of constants and functions
  25.  *   for older versions of PHP
  26.  *
  27.  * Optionally, you may simply include the file.
  28.  *   e.g. require_once 'PHP/Compat/Function/scandir.php';
  29.  *
  30.  * @category    PHP
  31.  * @package     PHP_Compat
  32.  * @version     0.1
  33.  * @author      Aidan Lister <aidan@php.net>
  34.  * @static
  35.  */
  36. class PHP_Compat
  37. {
  38.  
  39.     /**
  40.      * Load a function, or array of functions
  41.      *
  42.      * @param   string|array   $function The function or functions to load.
  43.      * @return  bool|array     true if loaded, false if not
  44.      */
  45.     function loadFunction ($function)
  46.     {
  47.         if (is_array($function)) {
  48.             $res = array ();
  49.             foreach ($function as $singlefunc{
  50.                 $res[PHP_Compat::loadFunction($singlefunc);
  51.             }
  52.             return $res;
  53.         }
  54.  
  55.         else {
  56.             if (!function_exists($function)) {
  57.                 $file sprintf('PHP/Compat/Function/%s.php'$function);
  58.  
  59.                 if ((@include_once $file!== false{
  60.                     return true;
  61.                 }
  62.             }
  63.  
  64.             return false;
  65.         }
  66.     }
  67.  
  68.  
  69.     /**
  70.      * Load a constant, or array of constants
  71.      *
  72.      * @param   string|array   $constant The constant or constants to load.
  73.      * @return  bool|array     true if loaded, false if not
  74.      */
  75.     function loadConstant ($constant)
  76.     {
  77.         if (is_array($constant)) {
  78.             $res = array ();
  79.             foreach ($constant as $singleconst{
  80.                 $res[PHP_Compat::loadConstant($singleconst);
  81.             }
  82.             return $res;
  83.         }
  84.  
  85.         else {
  86.             if (!defined($constant)) {
  87.                 $file sprintf('PHP/Compat/Constant/%s.php'$constant);
  88.                 
  89.                 if ((@include_once $file!== false{
  90.                     return true;
  91.                 }
  92.             }
  93.  
  94.             return false;
  95.         }
  96.     }
  97.  
  98. }
  99.  
  100. ?>

Documentation generated on Mon, 11 Mar 2019 10:17:00 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.