讲述了php判断是否连接上网络的方法。
<?php function varify_url($url){ $check = @fopen($url,"r"); if($check){ $status = true; }else{ $status = false; } return $status; }
接着在需要的地方直接调用即可。如下:
$url = "http://www.youkud.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>"; }