警告if(首先EREG错误,然后其他错误



这是我下面列出的原始代码。

if(ereg($pattern,strtolower($this->get_domain())) && !ereg("^-|-$",strtolower($this->get_domain())) && !preg_match("/--/",strtolower($this->get_domain()))){

这是错误

defeced:

中的函数ereg()

然后,我用下面的preg_match代替了EREG。我收到这个错误

if(preg_match($pattern,strtolower($this->get_domain())) && !preg_match("^-|-$",strtolower($this->get_domain())) && !preg_match("/--/",strtolower($this->get_domain()))){

警告:preg_match()[function.preg-match]:无结尾定界符'^' 在

中发现

我试图将/放在^之前和$之后,但仍然没有运气。我可以从可能知道如何解决此错误的人那里得到一些帮助。

将定界器添加到您的正则:

$pattern = "/^[a-z".$idn."0-9-]{3,}$/";// same for "/^[a-z0-9-]{3,}$/"
//   here __^             and here __^
if(preg_match($pattern, strtolower($this->get_domain())) && 
  !preg_match("/^-|-$/",strtolower($this->get_domain())) && 
  //         __^   __^
  !preg_match("/--/", strtolower($this->get_domain()))){

最新更新