On Fri, Aug 10, 2012 at 5:36 AM, Jim Lucas <li...@cmsws.com> wrote:
> 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

Why on earth would you want to reinvent the wheel? There's no point in
saying that fopen/fread/fclose is better, in fact, let me quote from
the manual page of file_get_contents:
"file_get_contents() is the preferred way to read the contents of a
file into a string. It will use memory mapping techniques if supported
by your OS to enhance performance."

If your solution would fix the problem (I doubt, but ok), then you
should report a bug to the PHP devs that file_get_contents is broken.

To the OP: Show some code, there might be something else.

- Matijn

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

Reply via email to