Home > php教程 > PHP源码 > body text

网址 url 正则表达式实例

WBOY
Release: 2016-06-08 17:27:56
Original
1205 people have browsed it
<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');
 }
}
?>




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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template