- <?php
- set_time_limit(0);
- $links = file('d.txt');
- function http_status($url) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- curl_setopt($ch, CURLOPT_NOBODY, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_exec($ch);
- $status = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE);
- curl_close($ch);
- // return ($status == 200) ? 1 : 0;
- return $status;
- }
- foreach ($links as $value) {
- $value = trim($value);
- echo $value . ' : <b>' . http_status($value) . '</b><br>';
- }
复制代码 php版本的。 |