截取url

 function geturl($url){
	
	$ch = curl_init();
        $timeout = 5;
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $content = curl_exec($ch);
		
        curl_close($ch);
	
		
if(preg_match_all("/(http|ftp|https)://([wd-_]+[.wd-_]+)[:d+]?([/]?[w/.?=&;%@#+,]+)/",$content,$a)){ //匹配字串中是否包至少两位到4位的数字
    echo "匹配!";
	$f=implode("",$a[0]);
 $fp2 = fopen('a.html', 'w');
    fwrite($fp2,$f);
    fclose($fp2);
}else{
    echo "不匹配!";
}
		
	
}

评论

刷新

友情链接