[] $ Body = ereg_replace ($ value, $ fileurl, $ body)

Source: Internet
Author: User
[Help] $ body = ereg_replace ($ value, $ fileurl, $ body) function & nbsp; remoteimg ($ imgurl) & nbsp ;{& nbsp; & nbsp; & nbsp; import ('@. ORG. session '); // Ses [help] $ body = ereg_replace ($ value, $ fileurl, $ body) is not included in the file header)
Function remoteimg ($ imgurl ){
Import ('@. ORG. session'); // A Session is not included in the file header.
$ Mid = Session: get ('mid '); // Obtain the mid
// Path of the file storage directory
$ ImgPath = "/Uploads/$ mid". date ('ymmd'). '/files/'; // url of the current date folder
Dir_create ($ imgPath); // create this directory
// File Save Directory URL
$ ImgUrl = _ ROOT _. '/'. $ imgPath; // Obtain the root parameter value configured in the current file.
Set_time_limit (0); // The code execution time limit. if the value is 0, the program execution is complete.
$ MilliSecond = date ("dHis"). '_'; // record the current date and time score in seconds
If (! Is_dir ($ imgPath) @ mkdir ($ imgPath, 0777); // create a directory if the directory does not exist (full permission)
$ Value = trim ($ imgurl); // remove spaces at both ends of the image address
$ Get_file = @ file_get_contents ($ value); // Obtain image data
$ RndFileName = $ imgPath. $ milliSecond. $ key. '. '. substr ($ value,-3, 3); // Generate the file path ???? $ Key ????
$ Fileurl = $ imgUrl. $ milliSecond. $ key. '.'. substr ($ value,-3, 3); // Generate the file path under the root path
If ($ get_file) {// if the file has been obtained
$ Fp = @ fopen ($ rndFileName, 'w'); // create a path and file
@ Fwrite ($ fp, $ get_file); // write image data
@ Fclose ($ fp); // Close the write data stream
$ Body = ereg_replace ($ value, $ fileurl, $ body); // check whether the $ body contains a string that matches the value. If yes, replace it with fileurl.
}
Echo $ body;
}

Who can explain the functions of this method?
What does $ body mean? Php variable ereg_replace shared:
------ Solution --------------------
$ Body only causes program errors!
------ Solution --------------------
If it weren't for you to paste the full code
Otherwise, it is not a normal practice to directly echo $ body in the function as the debugging code left by the author.

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.