PHP variable Ereg_replace
function Remoteimg ($imgurl) {import (' @.org. Session ');//do not include session $mid the file Header = Session::get (' mid ');//get mid//File save directory path $imgPath = "/uploads/$mid". Date (' YMD ' ).' /files/';//current Date folder URL dir_create ($imgPath);//create this directory//File save directory URL $imgUrl = __root__. ' /'. $imgPath;//Take the root parameter value configured under the current file Set_time_limit (0);//Code Execution time limit, 0 unlimited know program execution completed $milliSecond = date ("DHIs"). ' _ ';//Record current datetime fractional seconds if (!is_dir ($imgPath)) @mkdir ($imgPath, 0777);//directory not present create directory (full permission) $value = Trim ($imgurl); Remove the space at both ends of the image address $get _file = @file_get_contents ($value);//Get picture data $rndFileName = $imgPath. $milliSecond. $key. SUBSTR ($value,-3, 3);//In the same day picture path generated file path???? $key???? $fileurl = $imgUrl. $milliSecond. $key. '. SUBSTR ($value,-3, 3);//Generate file path under root path if ($get _file) {//If the file has been taken $fp = @fopen ($rndFileName, ' w ');//create path, file @fwrite ($fp, $get _file);//write image Data @fclose ($FP);//Turn off write data stream $body = ereg_replace ($value, $fileurl, $body) ;//Check if there is a string in the $body that matches the value, some words with FileURLReplace} echo $body;}
Question: Who can explain what the function of this method is?
What does it mean to use $body?
Reply to discussion (solution)
$body will only make the program error!
$body will only make the program error! The PHP website said that the use of uninitialized variables will be an error. But what is the function of this method? I added all the notes, but Nen didn't understand what he wanted to do ...
If you hadn't posted the full code,
Or the author left the debug code, the function of the direct echo $body; It's not a normal practice
function should be the download picture saved to the site local
Body speculation is the source of other web site down, and the inside of the image is also downloaded, the original image address to replace the site address
But the procedure here is problematic and should be like
If you hadn't posted the full code,
Or the author left the debug code, the function of the direct echo $body; It's not a normal practice
It feels like it was written together.
$body = Get content ... remoteimg content omitted if ($get _file) {//If the file has been obtained $fp = @fopen ($rndFileName, ' w ');//create path, file @fwrite ( $FP, $get _file);//write image Data @fclose ($FP);//Turn off write data stream $body = ereg_replace ($value, $fileurl, $body);//Check $ If there is a string in the body that matches the value, some words are replaced with FileURL } echo $body;
But then, when it was packaged, it went straight to the head.