CompatPhp4.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Add a few 4.3.0 functions to old versions of PHP
  4. *
  5. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  6. * @copyright (c) 2003 amfphp.org
  7. * @package flashservices
  8. * @subpackage io
  9. * @version $Id$
  10. */
  11. if (!function_exists("ob_get_clean")) {
  12. function ob_get_clean() {
  13. $ob_contents = ob_get_contents();
  14. ob_end_clean();
  15. return $ob_contents;
  16. }
  17. }
  18. if(!function_exists("file_put_contents")) {
  19. if (!defined('FILE_APPEND')) {
  20. define('FILE_APPEND', 8);
  21. }
  22. function file_put_contents($file, $string, $modifiers = NULL) {
  23. $mode = $modifiers == FILE_APPEND ? 'a' : 'w';
  24. $f=fopen($file, $mode);
  25. $result = fwrite($f, $string);
  26. fclose($f);
  27. return $result;
  28. }
  29. }
  30. function patched_array_search($needle, $haystack, $strict = FALSE) //We only need strict actually
  31. {
  32. foreach($haystack as $key => $val) {
  33. if ($needle === $val) {
  34. return($key);
  35. }
  36. }
  37. return FALSE;
  38. }
  39. function microtime_float()
  40. {
  41. list($usec, $sec) = explode(" ", microtime());
  42. return ((float)$usec + (float)$sec);
  43. }
  44. if(!function_exists('is_a'))
  45. {
  46. //We only use is_a as a replacement for PHP5-related stuff, so we always return false
  47. //anyways
  48. function is_a($obj, $d)
  49. {
  50. return false;
  51. }
  52. }
  53. ?>