[Help] $body = Ereg_replace ($value, $fileurl, $body)

Source: Internet
Author: User
Tags php website
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.
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.