{"id":6805,"date":"2014-04-23T08:07:27","date_gmt":"2014-04-23T08:07:27","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/fatal-error-stops-execution-in-php-collection-of-common-programming-errors\/"},"modified":"2014-04-23T08:07:27","modified_gmt":"2014-04-23T08:07:27","slug":"fatal-error-stops-execution-in-php-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/fatal-error-stops-execution-in-php-collection-of-common-programming-errors\/","title":{"rendered":"Fatal Error stops execution in PHP-Collection of common programming errors"},"content":{"rendered":"<p>I have following code in PHP<\/p>\n<pre><code>foreach($arr as $u){\n    \/\/code runs for users\n    $u-&gt;fetchFriends();\n}\n\nfunction fetchFriends(){\n\n$sparam = array('method' =&gt; 'fql.query', \n                'query' =&gt; $fql, \n                'callback' =&gt; '', \n                'access_token' =&gt; $fbtoken);\n\n    try{\n        $fqlResult = $facebook -&gt; api($sparam);\n        }\n    catch(Exception $e) {\n        echo 'There is issue with Token';\n    }\n}\n<\/code><\/pre>\n<p>The problem is that if the FB API throws an exception, then the process stops and next users in foreach loop doesn&#8217;t get executed. I want that even if it throws an error, the foreach loop should run for all users. Is that possible?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have following code in PHP foreach($arr as $u){ \/\/code runs for users $u-&gt;fetchFriends(); } function fetchFriends(){ $sparam = array(&#8216;method&#8217; =&gt; &#8216;fql.query&#8217;, &#8216;query&#8217; =&gt; $fql, &#8216;callback&#8217; =&gt; &#8221;, &#8216;access_token&#8217; =&gt; $fbtoken); try{ $fqlResult = $facebook -&gt; api($sparam); } catch(Exception $e) { echo &#8216;There is issue with Token&#8217;; } } The problem is that if the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6805","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6805"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6805\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}