2013-05-05 49 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

相關問題