PageRenderTime 113ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/pear/Compat/Function/file_get_contents.php

https://github.com/oilcf/agilebill
PHP | 57 lines | 23 code | 5 blank | 29 comment | 5 complexity | 2f4aa7acf7d94889d8a5b9daf6f49346 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, Apache-2.0, LGPL-2.0
  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP Version 4 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1997-2004 The PHP Group |
  6. // +----------------------------------------------------------------------+
  7. // | This source file is subject to version 3.0 of the PHP license, |
  8. // | that is bundled with this package in the file LICENSE, and is |
  9. // | available at through the world-wide-web at |
  10. // | http://www.php.net/license/3_0.txt. |
  11. // | If you did not receive a copy of the PHP license and are unable to |
  12. // | obtain it through the world-wide-web, please send a note to |
  13. // | license@php.net so we can mail you a copy immediately. |
  14. // +----------------------------------------------------------------------+
  15. // | Authors: Aidan Lister <aidan@php.net> |
  16. // +----------------------------------------------------------------------+
  17. //
  18. // $Id: file_get_contents.php,v 1.1 2005/07/23 05:56:03 Tony Exp $
  19. /**
  20. * Replace file_get_contents()
  21. *
  22. * @category PHP
  23. * @package PHP_Compat
  24. * @link http://php.net/function.file_get_contents
  25. * @author Aidan Lister <aidan@php.net>
  26. * @version $Revision: 1.1 $
  27. * @internal resource_context is not supported
  28. * @since PHP 5
  29. * @require PHP 4.0.0 (user_error)
  30. */
  31. if (!function_exists('file_get_contents')) {
  32. function file_get_contents($filename, $incpath = false, $resource_context = null)
  33. {
  34. if (false === $fh = fopen($filename, 'rb', $incpath)) {
  35. user_error('file_get_contents() failed to open stream: No such file or directory',
  36. E_USER_WARNING);
  37. return false;
  38. }
  39. clearstatcache();
  40. if ($fsize = @filesize($filename)) {
  41. $data = fread($fh, $fsize);
  42. } else {
  43. $data = '';
  44. while (!feof($fh)) {
  45. $data .= fread($fh, 8192);
  46. }
  47. }
  48. fclose($fh);
  49. return $data;
  50. }
  51. }
  52. ?>