note 36722 modified in function.file-get-contents by pollita
| From: | pollita@php.net | Date: | Mon, 16 Feb 2004 00:38:35 +0000 |
| Subject: | note 36722 modified in function.file-get-contents by pollita | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65188@lists.php.net to get a copy of this message | ||
Users of PHP4 < 4.3.0 can use the following:
It is binary safe and it can be used for external files.
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($filename, $use_include_path = 0) {
$data = '';
$file = @fopen($filename, "rb", $use_include_path);
if ($file) {
while (!feof($file)) $data .= fread($file, 1024);
fclose($file);
} else {
/* There was a problem opening the file. */
return FALSE;
}
return $data;
}
}
?>
--was--
Users of PHP4 < 4.3.0 can use the following:
It is binary safe and it can be used for external files.
<?php
if (!function_exists("file_get_contents")) {
function file_get_contents($filename, $use_include_path = 0) {
$data = ""; // just to be safe. Dunno, if this is really needed
$file = @fopen($filename, "rb", $use_include_path);
if ($file) {
while (!feof($file)) $data .= fread($file, 1024);
fclose($file);
}
return $data;
}
}
?>
http://www.php.net/manual/en/function.file-get-contents.php