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]
|