2013-04-05 29 views
0

我有以下的WordPress的代码PHP的preg_replace错误WordPress的

function shortcode_parse_atts($text) { 
    $atts = array(); 
    $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/'; 
    $text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text); 
    if (preg_match_all($pattern, $text, $match, PREG_SET_ORDER)) { 
     foreach ($match as $m) { 
      if (!empty($m[1])) 
       $atts[strtolower($m[1])] = stripcslashes($m[2]); 
      elseif (!empty($m[3])) 
       $atts[strtolower($m[3])] = stripcslashes($m[4]); 
      elseif (!empty($m[5])) 
       $atts[strtolower($m[5])] = stripcslashes($m[6]); 
      elseif (isset($m[7]) and strlen($m[7])) 
       $atts[] = stripcslashes($m[7]); 
      elseif (isset($m[8])) 
       $atts[] = stripcslashes($m[8]); 
     } 
    } else { 
     $atts = ltrim($text); 
    } 
    return $atts; 
} 

后,我与一个路径执行的功能,我得到这个错误:

Warning: preg_replace() [function.preg-replace]: Compilation failed: unknown option bit(s) set at offset -1 in /PATH/wp-includes/shortcodes.php on line 258

258线在这里打上

$text = preg_replace("/[\x{00a0}\x{200b}]+/u", " ", $text); //<--- LINE 258 

任何人都可以提供任何帮助吗?

,将不胜感激

广东话降级PHP版本...

+0

不知道这是否是问题,但你也可以试试''X的\\ {} HHHH代替'\ x {hhhh}'双引号。 – Passerby 2013-04-05 03:36:44

+1

检查这一个:[不正确的pcre版本] [1]。可能有一些回答您的问题就在这里 [1]:http://stackoverflow.com/questions/9323228/phpinfo-is-reporting-incorrect-pcre-version – 2013-04-05 03:39:34

回答

1

那是因为你的PCRE是过时的。将PHP更新为5.3版后,您需要手动更新服务器的PCRE。

在SSH运行下面的代码:

pcretest -C 

它会告诉你该版本的它运行。最后一个版本是8.32。

下面是你应该每个PHP版本使用PCRE版本的关系: http://php.net/manual/en/pcre.installation.php

+0

感谢球员,我得到的主机重新编译apache – 2013-04-07 02:39:13