a.php
<?php
header("Content-type: text/html; charset=utf-8");
date_default_timezone_set("Asia/Shanghai");
$start = microtime(true);
function fsockopen_get($domain, $url)
{
$fp = fsockopen($domain, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "GET " . $url . " / HTTP/1.1\r\n";
$out .= "Host: " . $domain . "\r\n";
$out .= "Connection: Close\r\n\r\n";
fwrite($fp, $out);
/*忽略执行结果
while (!feof($fp)) {
echo fgets($fp, 128);
}*/
fclose($fp);
}
}
fsockopen_get('temp.com', '/b.php');
$end = microtime(true);
$time= $end - $start;
//精确到十位小数,可自行调节
echo number_format($time, 10, '.', '')." seconds";
b.php
<?php
header("Content-type: text/html; charset=utf-8");
file_put_contents('54321.log', microtime(true), FILE_APPEND);
sleep(20);
file_put_contents('54321.log', microtime(true), FILE_APPEND);
【推荐】2025 HarmonyOS 鸿蒙创新赛正式启动,百万大奖等你挑战
【推荐】博客园的心动:当一群程序员决定开源共建一个真诚相亲平台
【推荐】开源 Linux 服务器运维管理面板 1Panel V2 版本正式发布
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步