Stripping CVS keywords
[project/wp2drupal.git] / php_compat / file_get_contents.php
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
19
20 /**
21 * Replace file_get_contents()
22 *
23 * @category PHP
24 * @package PHP_Compat
25 * @link http://php.net/function.file_get_contents
26 * @author Aidan Lister <aidan@php.net>
27 * @version $Revision$
28 * @internal resource_context is not supported
29 * @since PHP 5
30 * @require PHP 4.0.0 (user_error)
31 */
32 if (!function_exists('file_get_contents')) {
33 function file_get_contents($filename, $incpath = false, $resource_context = null) {
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
40 clearstatcache();
41 if ($fsize = @filesize($filename)) {
42 $data = fread($fh, $fsize);
43 }
44 else {
45 $data = '';
46 while (!feof($fh)) {
47 $data .= fread($fh, 8192);
48 }
49 }
50
51 fclose($fh);
52 return $data;
53 }
54 }
55
56 ?>