You are here: Re: file_get_contents vs readfile « PHP Programming Language « IT news, forums, messages
Re: file_get_contents vs readfile

Posted by Erwin Moller on 09/10/07 14:21

howa 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?
>

According to www.php.net:

file_get_contents() is the preferred way to read the contents of a file
into a string. It will use memory mapping techniques if supported by
your OS to enhance performance.

But that aside, I don't know what is better.
You could try to see if a huge file give better performance with
file_get_contents(), but I expect the networktraffic is a much bigger
concern than the servers file-IO.

Regards,
Erwin Moller

 

Navigation:

[Reply to this 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

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