页面无法加载的原因可能是什么?我目前正在向我的机器人发送一个请求,它会给我发回一个响应,但不知何故,如果机器人在线并工作,页面就不会加载。有没有办法得到这个错误?我有一个cPanel,display_errors是1。还有其他想法吗?
这是我的一个要求:
function getData($Id) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://IPAdress:8000/Data/".$Id);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$server_output = curl_exec($ch);
curl_close ($ch);
return $server_output;
}发布于 2021-06-21 16:42:03
curl_errno()和curl_error()通常就足够了,
$server_output = curl_exec($ch);
$errstr=null;
if(curl_errno($ch)){
$errstr = curl_errno($ch).": ".curl_error($ch);
}
curl_close ($ch);
if(isset($errstr)){
echo $errstr;
}有时,您可以通过添加CURLOPT_VERBOSE来获取更多信息
$stderrh=tmpfile();
curl_setopt_array($ch,array(CURLOPT_VERBOSE=>1,CURLOPT_STDERR=>$stderrh));
$server_output = curl_exec($ch);
/* https://bugs.php.net/bug.php?id=76268 */
rewind($stderrh);
$stderr=stream_get_contents($stderrh);
fclose($stderrh);
$errstr=null;
if(curl_errno($ch)){
$errstr = curl_errno($ch).": ".curl_error($ch)." verbose: ".$stderr;
}
curl_close ($ch);
if(isset($errstr)){
echo $errstr;
}但这通常是一种过度杀伤力
https://stackoverflow.com/questions/68064801
复制相似问题