Reply to Re: file_get_contents vs readfile

Your name:

Reply:


Posted by gosha bine on 09/10/07 15:00

On 10.09.2007 16:23 howa wrote:
> On 9 10 , 10 20 , ZeldorBlat <zeldorb...@gmail.com> wrote:
>> On Sep 10, 10:07 am, howa <howac...@gmail.com> wrote:
>>
>>> Target: To fetch a file using PHP and send to user
>>> Method 1:
>>> echo file_get_contents( $file_path );
>>> Method 2:
>>> readfile( $file_path );
>>> Which one is better?
>> In practice it probably doesn't make much of a difference. In this
>> case, however, I'd use readfile since the function was intended to do
>> exactly what it is that you're trying to do.
>
> from the doc it said:
>
> file_get_contents() is the preferred way to read the contents of a
> file into a string
>
> also, readfile() also need to read the entrie file into memory before
> send to buffer, so I am just wondering which is better.
>
>

Actually, readfile doesn't read the whole file, it uses mmap if
possible, otherwise reads/writes in 8K chunks, thus conserving memory.



--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация