Last active
July 15, 2024 08:16
-
-
Save akccakcctw/e98b94c22e4a009330d6a9f988f09f19 to your computer and use it in GitHub Desktop.
dns_lookup_time.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = 'http://google.com'; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
// 啟用 CURL 信息 | |
curl_setopt($ch, CURLINFO_HEADER_OUT, true); | |
// 啟用詳細的 CURL 信息 | |
curl_setopt($ch, CURLOPT_VERBOSE, true); | |
// 執行 CURL 请求 | |
curl_exec($ch); | |
// 獲取 CURL 傳輸信息 | |
$info = curl_getinfo($ch); | |
if ($info === FALSE) { | |
echo 'CURL Error: ' . curl_error($ch); | |
} else { | |
echo "DNS解析時間: " . $info['namelookup_time'] . " 秒\n"; | |
} | |
// 關閉 CURL 请求 | |
curl_close($ch); | |
die; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment