Good error handling with file_get_contents

后端 未结 5 1647
梦如初夏
梦如初夏 2020-11-30 10:26

I am making use of simplehtmldom which has this funciton:

// get html dom form file
function file_get_html() {
    $dom = new simple_html_dom;
    $args = fu         


        
5条回答
  •  [愿得一人]
    2020-11-30 10:34

    IF youre fetching from an external URL the best handling is going to come fromt he introduction of HTTP library like Zend_Http. This isnt much different than using CURL or fopen except its going to extract the particulars of these "dirvers" into a universal API and then you can choose which you want to use. Its also going to have some built in error trapping to make it easier on you.

    If you dont want the overhead of another library then you can code it yourself obviously - in which case i always prefer CURL.

提交回复
热议问题