[求助]$body = ereg_replace( $value, $fileurl, $body )
function remoteimg($imgurl) {
import('@.ORG.Session');//不在檔案頭部需包含Session
$mid = Session::get('mid');//擷取mid
//檔案儲存目錄路徑
$imgPath = "/Uploads/$mid".date( 'Ymd' ).'/files/';//當前日期檔案夾url
dir_create($imgPath);//建立這個目錄
//檔案儲存目錄URL
$imgUrl = __ROOT__.'/'. $imgPath;//取當前檔案下配置的root參數值
set_time_limit( 0 );//代碼執行時間限制,為0無限制知道程式執行完畢
$milliSecond = date( "dHis" ) . '_';//記錄當前的日期時間分數秒數
if ( !is_dir( $imgPath ) ) @mkdir( $imgPath, 0777 );//目錄不存在則建立目錄(完全許可權)
$value = trim( $imgurl );//去除圖片地址兩頭的空格
$get_file = @file_get_contents( $value );//擷取圖片資料
$rndFileName = $imgPath.$milliSecond.$key.'.'.substr( $value, -3, 3 );//在當天圖片路徑下組建檔案路徑 ????$key????
$fileurl = $imgUrl.$milliSecond.$key.'.'.substr( $value, -3, 3 );//在root路徑下組建檔案路徑
if ( $get_file ) {//如果已經取得檔案
$fp = @fopen( $rndFileName, 'w' );//建立路徑、檔案
@fwrite( $fp, $get_file );//寫入圖片資料
@fclose( $fp );//關閉寫入資料流
$body = ereg_replace( $value, $fileurl, $body );//檢查$body中是否有與value匹配的字串,有的話用fileurl替換掉
}
echo $body;
}
如題:誰能解釋下這個方法的功能是什嗎?
$body的用法是什麼意思? php 變數 ereg_replace
分享到:
------解決方案--------------------
$body 只會讓程式出錯!
------解決方案--------------------
要不是你沒有貼全代碼
要不就是作者遺留的調試代碼,函數裡直接 echo $body; 並不是正常做法