2013-04-05 30 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