Re: Trapping failure of file_get_contents()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:
> 
> <?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.


To squelch the warning notice that is generated, you might want to put an @ in
front of the file_get_contents() call.

Jim

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux