...

View Full Version : Getting file contents (which one takes up less resources)



WebmasterLULZ
12-16-2008, 10:25 PM
So i have a php script that will get the contents of a file that is around 3MB or so, however allot of users will be calling up on this script. Which one of these is best to get contents of a offsite file.

readfile, fopen, file_get_contents. Any others? i need to use as little system resources as possible, which one uses the least system resources as well as very effective to grab all the contents of a 3-5MB file.

Fumigator
12-17-2008, 01:27 AM
You don't want to use readfile(), unless you also want to output the file contents (to browser or other place).

fopen() doesn't read anything; fread() does but is much slower than file_get_contents().

file() can also be used but but manual says file_get_contents() is faster.

dk01
12-17-2008, 01:55 AM
If you prefer, you might check out curl for speed and security. Much better than the standard php file functions.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum