If error then continue and not die - possible?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
oskare100
Forum Commoner
Posts: 80
Joined: Sun Oct 29, 2006 5:47 am

If error then continue and not die - possible?

Post 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
bertfour
Forum Commoner
Posts: 45
Joined: Fri Mar 07, 2008 7:33 am

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

Post by bertfour »

Yes...

Code: Select all

$request = file_get_contents($request_url);
 
if (!$request) {
echo "feed not loading";
}
 
 
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

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

Post by Ambush Commander »

Granted, it's a bit easier to use conditionals if you've split your functionality into functions. :-)
Post Reply