note 30521 deleted from function.file-get-contents by didou
| From: | didou@php.net | Date: | Thu, 18 Sep 2003 14:05:39 +0000 |
| Subject: | note 30521 deleted from function.file-get-contents by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-56689@lists.php.net to get a copy of this message | ||
Note Submitter: php@mijav.dk
----
I was recently running some PHP version prior to 4.3.0 and had a small script loading a very large
file containing some HTML - I made some regular expression matches on content and it went quite
fast..(- I had less than a second execution time).
I then upgraded to PHP 4.3.0 and suddenly my script ate my CPU and halted after 30 seconds. It seems
since they made the function binary-safe the performance hit rock bottom.
My advice: If you have rather large files (something like >1 MB) - I suggest you use fopen() and
fread() :
$fp = fopen($file,"r");
$content = fread($fp,filesize($file));
... /* Do something */
fclose($fp);
This did the trick for me, my execution time is now back to normal. (Note: I did however test file()
on smaller files, though slow, it worked - and I also tested file() on a fresh installation)
Specs.: AMD Athlon XP 1800+, 256 MB RAM, Windows 2000 (and XP tried), Apache 1.3, PHP 4.2.3