调用 Inflector 类的 slug 方法时出现一个奇怪的错误。这是代码:
Inflector::slug('foo', '-');
我得到的错误是:
警告(2):preg_replace():编译失败:偏移量 0 处没有可重复的内容 [CORE/Cake/Utility/Inflector.php,第 546 行]
这是方法slug:
public static function slug($string, $replacement = '_') {
$quotedReplacement = preg_quote($replacement, '/');
$merge = array(
'/[^\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ',
'/\\s+/' => $replacement,
sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '',
);
$map = self::$_transliteration + $merge;
return preg_replace(array_keys($map), array_values($map), $string);
}
任何想法是什么导致了错误?
附加信息:http ://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html