Re: Too many open files

From: Date: Fri, 10 Aug 2012 05:54:43 +0000
Subject: Re: Too many open files
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-318664@lists.php.net to get a copy of this message
On 8/9/2012 9:40 PM, Alan Hoffmeister wrote:
+1 to fopen and fclose. You can implement your function: function read($file){ if ( $fh = fopen($file, 'r') ) {
     $data = fread($fh, filesize($file));
     fclose($fh);
} } echo read('hello-world.txt'); echo read('hello-world1.txt'); echo read('hello-world2.txt'); echo read('hello-world3.txt'); This way you will close one file before start reading the other one. -- Att, Alan Hoffmeister
You top posted AND you didn't send it to the list... Jim
2012/8/10 Jim Lucas <lists@cmsws.com>:
On 8/9/2012 5:01 PM, Al wrote:
Getting "Too many open files" error when processing an email batch process. I've looked extensively and can't find more than about 100 files that could be open. All my fetching is with get_file_contents();
Why not use fopen() and other related functions to open/grap/close your batch of files? You could replace a call like this: $data = file_get_contents($filename); with this: if ( $fh = fopen($filename, 'r') ) { $data = fread($fh, filesize($filename)); fclose($fh); } This should take care of your issue. Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#318664) next »