Re: Quick file_get_contents() questions...your opinion needed

From: Date: Mon, 11 Oct 2004 19:30:28 +0000
Subject: Re: Quick file_get_contents() questions...your opinion needed
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-199230@lists.php.net to get a copy of this message
* Thus wrote Mag: > I did look at the fopen option...but it just seemed a > little longer and more complicated to do that plus > according to this benchmark > (http://force-elite.com/~chip/projects/php/benchmarks/file-vs-fgets/) > using file_get_contents is upto 6 times faster (?) in > some cases.. You certaintly dont want to do a file() on a 20MB file. There are times when you'll want to use fopen vs file/file_get_contents. file_get_contents will be much faster for a couple of reasons. for one, getting the same results as file_get_contents you have to do something like: $string = implode("\n", file($file)); Another reson file_get_contents() will be faster is because it uses (when available on the OS) a special memory allocation that is much more efficiant, than other file reading tools. Curt -- Quoth the Raven, "Nevermore."

« previous php.general (#199230) next »