独家专供:PHP的URL印证正则算法,有史以来最强悍的

WBOY
Release: 2016-06-13 11:36:56
Original
794 people have browsed it

独家专供:PHP的URL验证正则算法,有史以来最强悍的

经过多年的积累,逐步完善写出的url验证算法

function isUrl($s){	return preg_match('/^http[s]?:\/\/'.		'(([0-9]{1,3}\.){3}[0-9]{1,3}'. // IP形式的URL- 199.194.52.184		'|'. // 允许IP和DOMAIN(域名)		'([0-9a-z_!~*\'()-]+\.)*'. // 三级域验证- www.		'([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.'. // 二级域验证		'[a-z]{2,6})'.  // 顶级域验证.com or .museum		'(:[0-9]{1,4})?'.  // 端口- :80		'((\/\?)|'.  // 如果含有文件对文件部分进行校验		'(\/[0-9a-zA-Z_!~\*\'\(\)\.;\?:@&=\+\$,%#-\/]*)?)$/',		$s) == 1;}
Copy after login

要是还遇到问题,请把有问题的url贴上来,希望还能继续完善

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template