Home >Backend Development >PHP Tutorial >php url regular matching

php url regular matching

WBOY
WBOYOriginal
2016-07-30 13:30:412132browse

URL regular matching code in PHP:

$regex = '/^(http|https|ftp):\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\’:+!]*([^<>\”])*$/';
$url = "http://www.baidu.com";
if (preg_match($regex, $url)) { 

	echo "Ture"; 
} else {

	echo "False";
} 

Copyright statement: This article is an original article by the blogger and may not be reproduced without the blogger's permission.

The above introduces PHP url regular matching, including aspects of content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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