Re: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Robert Cummings
Marshall Burns wrote: I have a script that downloads a sequence of files online. Every hundred files or so, it fails with: Check for the return value being equal to false: Make sure you use the triple '=' comparison operator since you need to check against the type being boolean also. Ch

Re: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Jim Lucas
Robert Cummings wrote: > > Marshall Burns wrote: >> I have a script that downloads a sequence of files online. Every hundred >> files or so, it fails with: > > Check for the return value being equal to false: > > > if( ($sFil = file_get_contents( $sURL )) === false ) > { > // F

RE: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Marshall Burns
mp;m=125622597723923&w=2 . Thanks. -Original Message- From: Robert Cummings [mailto:rob...@interjinn.com] Sent: Thursday, October 22, 2009 08:44 To: Marshall Burns Cc: php-general@lists.php.net Subject: Re: [PHP] Trapping failure of file_get_contents() Marshall Burns wrote: > I have a

Re: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Robert Cummings
Marshall Burns wrote: Robert and others, I made that change in the code. It still does not trap the failure. I believe the reason is that the script is timing out while file_get_contents() is sitting there waiting for input. The problem is that the function never returns, so there is no return v

Re: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Gerardo Benitez
Hi Marshall, the function file_get_contents may have problem with large files. You could try get the file using "fread" and feof. Here i put a example $contents = ''; while(!feof($stream)){ $contents .= fread($stream, 8192); } Gerardo Benitez. On Thu, Oct 22, 2009 at 12:38 PM, Mars

RE: [PHP] Trapping failure of file_get_contents()

2009-10-22 Thread Marshall Burns
} curl_close($oChandle); if($bWriteFile) fclose($oFilePtr); return($sRetVal); } -Original Message- From: Robert Cummings [mailto:rob...@interjinn.com] Sent: Thursday, October 22, 2009 11:21 To: Marshall Burns Cc: php-general@lists.php.net Subject: Re: [