Ec (2); ob_start: Open the output buffer readfile: reads a file and writes it to the output buffer to return the number of bytes read from the file. If an error is returned, FALSE is returned, and the error message is displayed unless called in the form of @ readfile. Ob_end_clean (): Clean (erase) theoutputbufferandturnoffoutputbuffering (clear output script ec (2); script 
 
Ob_start: Enable the output buffer.
 
Readfile: reads a file and writes it to the output buffer.
Returns the number of bytes read from the file. If an error is returned, FALSE is returned, and the error message is displayed unless called in the form of @ readfile.
 
Ob_end_clean (): Clean (erase) the output buffer and turn off output buffering (clear output buffer)
 
 // The URL is the complete remote image address and cannot be blank. $ filename is the name of the saved image.
// By default, images are stored in the same directory as the script.
Function GrabImage ($ url, $ filename = ""){
// If $ url is null, false is returned;
If ($ url = "") {return false ;}
$ Ext = strrchr ($ url, "."); // get the image extension.
If ($ ext! = ". Gif" & $ ext! = ". Jpg" & $ ext! = ". Bmp") {echo "format is not supported! "; Return false ;}
If ($ filename = "") {$ filename = time (). "$ ext";} // name it with a timestamp
// Start capturing
Ob_start ();
Readfile ($ url );
$ Img = ob_get_contents ();
Ob_end_clean ();
$ Size = strlen ($ img );
$ Fp2 = fopen ($ filename, "");
Fwrite ($ fp2, $ img );
Fclose ($ fp2 );
Return $ filename;
}
// Test
GrabImage ("http://www.111cn.net tutorial/banner/banner.gif", "as.gif ");
?>