Page 1 of 1

If error then continue and not die - possible?

Posted: Fri Mar 07, 2008 4:14 pm
by oskare100
Hello,
I have the following code:

Code: Select all

$request = file_get_contents($request_url) or die("feed not loading");


If the file_get_contents($request_url) doesn't load/respond then the script echoes "feed not loading" and stops.

I want the script to echo "feed not loading" and then continue and just skip that part of the script that needed the file contents.

Is that possible?

Best Regards
Oskar R

Re: If error then continue and not die - possible?

Posted: Fri Mar 07, 2008 4:22 pm
by bertfour
Yes...

Code: Select all

$request = file_get_contents($request_url);
 
if (!$request) {
echo "feed not loading";
}
 
 

Re: If error then continue and not die - possible?

Posted: Fri Mar 07, 2008 11:08 pm
by Ambush Commander
Granted, it's a bit easier to use conditionals if you've split your functionality into functions. :-)