php preg_match揭示警告

WBOY
Release: 2016-06-13 12:08:49
Original
939 people have browsed it

php preg_match提示警告。
代码如下:

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



运行结果:
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"
------解决思路----------------------
对于斜杠   如果你不想转移   就用  # 或者 @  或者 ! 都行 
------解决思路----------------------
少了轉意義,所以出錯。

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!