我试图做脚本,检查站点是否启动或关闭。一切工作正常,但当网站不是一个网站,我的意思是该网站不存在。然后php执行加载时间增加。我想以某种方式处理这个问题。如何检查网站是否存在并打破卷曲会话?这里是我的脚本:PHP:如何处理卷曲响应
<?php
$ch = curl_init('http://86.100.69.228/'); // e.g. for this will increase execution time because the site doesn't exists
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $status_code;
curl_close($ch);
?>