PHP判断是否连接上网络的小例子
时间:2021-07-01 10:21:17
帮助过:30人阅读
- //检测网络是否连接
- function varify_url($url){
- $check = @fopen($url,"r");
- if($check){
- $status = true;
- }else{
- $status = false;
- }
- return $status;
- } //by bbs.it-home.org
调用示例:
- $url = "http://bbs.it-home.org";
- if(varify_url($url)){
- echo "Congratulation ! Your URL $url : is valid ";
- }else{
- echo "Error ! 你提供的URL : $url is invalid ";
- }
|