我想检查我的数据库中是否有可用的url。我选择
fopen
,但是我从我的数据库测试30行,这将花费近20秒的时间。有没有什么方法可以使它更有效率?谢谢。<?php
$start_t = microtime(true);
//connect database and select query
while ($row = mysql_fetch_array($result)){
//$url = 'http://www.google.com'; //not test from database, but a google.com, one url will cost 0.49 seconds.
$url = $row['url'];
$res = @fopen($url, "r ");
if($res){
echo $row['url'].' yes<br />';
}else{
echo $row['url']. ' no<br />';
}
}
$end_t = microtime(true);
$totaltime = $end_t-$start_t;
echo "<br />".$totaltime." s";
?>