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 <li...@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



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

Reply via email to