日期:2011-08-05 浏览次数:20501 次
php中检查某个网页地址是否有效能被打开的最简单方法,其实可以用下面的方法:
function varify_url($url)
{
$check = @fopen($url,"r");
if($check)
$status = true;
else
$status = false;
return $status;
}
使用:
$url = "http://www.google.com";
if(varify_url($url))
{
echo "<div>Congratulation ! Your URL <a href=$url>$url</a> : is <b>valid </b></div>";
}
else
{
echo "<div>Error ! Your URL : <a href=$url>$url</a> is <b>invalid </b></div>";