@REM<?php
@REM =='
@SET PHPCLI=D:/phpStudy/php55n/php.exe
@%PHPCLI% %0
@goto :EOF
@REM';?>
<?php
// 使用前需要将第3行代码的 PHPCLI 路径改为你本机的php.exe所在路径
function httpcode($url){
  $ch = curl_init();
  // $timeout = 3;
  curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
  curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  curl_setopt($ch, CURLOPT_HEADER, 1);
  // curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  curl_setopt($ch,CURLOPT_URL,$url);
  curl_exec($ch);
  return $httpcode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
  curl_close($ch);
}
  while (true) {
    sleep(5);
    // 调用函数 , 获取实时状态
    $code = httpcode('http://www.xygyhd.org/');
    if($code != '200') {
      echo 'host is bad! ' . "\n";
    } else {
      echo 'host is ok!' . "\n";
    }
  }
exec("pause");
?>

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2021-05-24
  • 2022-12-23
  • 2022-01-01
  • 2021-07-01
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案