Fsockopen error handling, at the moment I get warnings and page stops further content from loading

雨燕双飞 提交于 2019-12-02 21:59:46

问题


I have the following code:

$open_socket = fsockopen($host,$port,$errno,$errstr,30);
if(!$open_socket){
    echo "$errstr ($errno)<br />".$nl;
}else{
    fputs($open_socket,$xml);
    while(!feof($open_socket)){
        $line = fgets($open_socket,128);
        $return_xml.= $line;
    }
    fclose($open_socket);
}

but if there is not connection I get the following message:

Warning: fsocket ......

the rest of the page is blank, basically how can I handle this where my page will continue and things will be displayed and just the error message is displayed and not the warning.

Thanks


回答1:


You can supress warnings calling fsockopen

$open_socket = @fsockopen($host,$port,$errno,$errstr,30);


来源:https://stackoverflow.com/questions/8239994/fsockopen-error-handling-at-the-moment-i-get-warnings-and-page-stops-further-co

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!