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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* 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."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux