note 27345 deleted from function.file-get-contents by didou
| From: | didou@php.net | Date: | Fri, 28 Nov 2003 16:38:04 +0000 |
| Subject: | note 27345 deleted from function.file-get-contents by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-61084@lists.php.net to get a copy of this message | ||
Note Submitter: davidw[nospam]ensky.com
----
Since file_get_contents() is identical to readfile(), except that it returns a string, you can just
use output buffering to capture the output of readfile(), if you're looking for a version of
this function for versions of php that don't have it:
e.g.
function file_get_contents($f) {
ob_start();
$retval = @readfile($f);
if (false !== $retval) { // no readfile error
$retval = ob_get_contents();
}
ob_end_clean();
return $retval;
}
You can use the same principle for any PHP function that outputs directly to the browser, instead of
returning results in a variable.