Forums

  • # July 3, 2013 at 10:41 am

    I want to protect my function from displaying errors when something is wrong loading external files but I can’t find any documentation about this.

    Here’s the code:
    $rss = new DOMDocument();
    $rss->load($feedSource);

    $feed = array();
    foreach ($rss->getElementsByTagName(‘item’) as $node) {
    $item = array (
    ‘title’ => $node->getElementsByTagName(‘title’)->item(0)->nodeValue,
    ‘desc’ => $node->getElementsByTagName(‘description’)->item(0)->nodeValue,
    ‘link’ => $node->getElementsByTagName(‘link’)->item(0)->nodeValue,
    ‘date’ => $node->getElementsByTagName(‘pubDate’)->item(0)->nodeValue,
    );
    array_push($feed, $item);
    }

    return $feed;

    # July 4, 2013 at 5:46 am

    In _this_ case hidding _is_ error handling. But not with display_errors off.

    I want to ensure that when the source of my feed goes down or change the structure of their xml document I’m able to hide the feed box from the website. Isn’t there any “try{ } catch{}” similar in PHP?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag