Home  >  Article  >  Backend Development  >  php preg_match提示警告。

php preg_match提示警告。

WBOY
WBOYOriginal
2016-06-23 13:46:391044browse

代码如下:

<?phpfunction isValidDomain($domain){	if(preg_match("/^(http|ftp)://(www\.)?.+\.(com|org|net)$/i",$domain))		return $domain.'是合法域名';	else		return $domain.'<b>不</b>是合法域名';}echo isValidDomain("http://www.aixi.com");?>



运行结果:
Warning: preg_match(): Unknown modifier '/' in D:\wamp\www\www.yoyou.com\this.php on line 3
http://www.aixi.com不是合法域名

ps:php是5.4版本


回复讨论(解决方案)

是怎么回事?哪位大神讲一下!!!

"/^(http|ftp): \/ \/(www\.)?.+\.(com|org|net)$/i"

" #^(http|ftp)://(www\.)?.+\.(com|org|net)$ #i"

原来要转义,要不然区别不了啊。
哈哈,多谢解答!

对于斜杠   如果你不想转移   就用  # 或者 @  或者 ! 都行 

少了?意?,所以出?。

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
Previous article:SEONext article:一张游览PHP内核迷宫的藏宝图