如何使用PHP curl检测此错误?即使URL不存在,curl也会返回成功.
原文链接:https://www.f2er.com/php/137483.htmlNot Found The requested URL /foo/index.PHP/items/edit was not found on this server.
我的代码
$post_fields = array('info' => json_encode($fields)); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,count($post_fields)); curl_setopt($ch,CURLOPT_POSTFIELDS,$post_fields); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLINFO_CONTENT_TYPE,'application/x-www-form-urlencoded charset=utf-8'); $result = curl_exec($ch); echo $result; if(curl_error($ch)){ $result = curl_error($ch); curl_close($ch); return $result; }else{ curl_close($ch); return json_decode($result,true); }