note 27345 added to function.file-get-contents
| From: | davidw at rack1 dot php dot net | Date: | Mon, 02 Dec 2002 20:29:18 +0000 |
| Subject: | note 27345 added to function.file-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-40276@lists.php.net to get a copy of this message | ||
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.
--
http://www.php.net/manual/en/function.file-get-contents.php
http://master.php.net/manage/user-notes.php?action=edit+27345
http://master.php.net/manage/user-notes.php?action=delete+27345
http://master.php.net/manage/user-notes.php?action=reject+27345