Re: Files passing through
| From: | Jasper Bryant-Greene | Date: | Mon, 22 Aug 2005 23:35:14 +0000 |
| Subject: | Re: Files passing through | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-221128@lists.php.net to get a copy of this message | ||
Kevin Waterson wrote:
This one time, at band camp, Philip Hallstrom <php@philip.pjkh.com> wrote:readfile() is the correct function for this purpose. fpassthru() is designed for if you need to seek to a particular point in the file and then output the remainder (or do other voodoo with the file pointer before outputting the contents), and file_get_contents() is for when you need the file contents in a string. However, the first comment on readfile() states that readfile() is 55% slower than doing a simple loop until EOF and using fread(). I haven't tested that claim, so YMMV. JasperMy guess would be because file_get_contents returns the contents as a string. So if 'myfile' is 100mb, you're going to have to allocate 100mb of memory to store that string while echo() spits it back out. But I'm just guessing as I don't know for sure...I think you got it, we really dont have enough information on what he has in myfile.txt