Re: Trapping failure of file_get_contents()
| From: | Robert Cummings | Date: | Thu, 22 Oct 2009 15:43:30 +0000 |
| Subject: | Re: Trapping failure of file_get_contents() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-299220@lists.php.net to get a copy of this message | ||
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: <?php
if( ($sFil = file_get_contents( $sURL )) === false )
{
// FAIL
}
else
{
// SUCCESS
}
?>
Make sure you use the triple '=' comparison operator since you need to check against the type being boolean also.
Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP