I'm loading a XML file from a foreign server which is working. But how do I receive an error message if the file does not exist or something else went wrong while loading it?
This is my code:
$xml = simplexml_load_file('http://api.example.com/2/image/' . $myhash . '.xml');
Also I'ld like to know what's the best practice if something like that happens. Should I just display an error message like "error - please reload page" or should I directly redirect the user like to the "homepage" or a 404 page?
Thanks for tips. (I've only found examples for files on the same server)