2013-05-05 47 views
0

我HABE用PHP 5.3和Joomla和错误显示这样 的preg_replace(一个问题)[ 'W' 在/ var/WWW/的preg_replace()[function.preg替换]:未知的修饰 'W' 中/var/www/.../public_html/

我的代码

$params = $this->item->params; 
$images = json_decode($this->item->images); 
$urls = json_decode($this->item->urls); 
$canEdit = $this->item->params->get('access-edit'); 
$user  = JFactory::getUser(); 

$imagesJson = json_decode($this->item->images); 
$images_stringPath = substr($imagesJson->image_fulltext, 0,strripos($imagesJson->image_fulltext, '/')); 
$path = "/".$images_stringPath; 



$tmp_filename=preg_replace($_SERVER["DOCUMENT_ROOT"].$path.'/','',$value); 
+0

为什么不使用'str_replace'? – Gumbo 2013-05-05 07:07:09

回答

0

使用preg_replace()为简单的字符串替换是矫枉过正未知的修饰:function.preg替换。改为使用str_replace()

无论如何,preg_replace()预计正则表达式模式包围“定界符”,你没有提供。

细讲,这是你的函数调用的外观:

$tmp = preg_replace('/var/www/.../', '', $value); 
//     ^ ^^ 
//     | || 
//     | |+--- "modifier" 
//     | +---- terminating delimiter 
//     +-------- starting delimiter 

起始定界符将斜杠/。在var之后终止模式。在终止分隔符后,preg_replace()允许optional modifiersw是他们中的任何一个。

+0

哦!感谢它工作! – 2013-05-05 07:09:17

相关问题