1
我有以下函数为脚本返回一个干净的路径。PHP preg_replace()编译失败:缺失)
function cleanPath($path) {
$path = (string) $path;
$path = preg_replace(
array(
'#[\n\r\t\0]*#im',
'#/(\.){1,}/#i',
'#(\.){2,}#i',
'#(\.){2,}#i',
'#('.DIRECTORY_SEPARATOR.'){2,}#i'
),
array(
'',
'',
'',
'/'
),
$path
)
;
return rtrim($path,DIRECTORY_SEPARATOR);
}
PHP提供了错误:
Warning: preg_replace() [function.preg-replace]: Compilation failed: missing) at offset 7 in C:\wamp\www\extlogin\app\ni\inc\classes\cfiletree.php on line 18
不好的事,以及如何解决它的任何想法?
谢谢。
有没有办法捕捉到这个特定的错误,即你可以在使用它之前“测试”一个模式? – 2013-02-19 09:05:22