Home >php教程 >PHP源码 >网址 url 正则表达式实例

网址 url 正则表达式实例

WBOY
WBOYOriginal
2016-06-08 17:27:561242browse
<script>ec(2);</script>

function funcUrl($str)//url正则表达试
 {
  return (preg_match("/^http://[A-Za-z0-9]+.[A-Za-z0-9]+[/=?%-&_~`@[]':+!]*([^""])*$/",$str))?true:false;
 }

if( $_POST)
{
 if( funcUrl( $_POST['url'] ) )
 {
  echo $_POST['url'];
 }
 else
 {
  exit('不是有效url');
 }
}
?>




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