The following is the source code, and its related explanations 
 
 
  
  Copy Code code as follows: 
 
 
  
 
  
  
<?php 
  
URL is a remote full picture address, can not be empty, $filename is saved as a picture name 
  
Default to put the picture in the same directory as this script 
  
function Grabimage ($url, $filename = "") { 
  
Returns False if the $url is empty; 
  
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 ";} A time stamp, another name. 
  
Start capturing 
  
Ob_start (); 
  
ReadFile ($url); 
  
$img = Ob_get_contents (); 
  
Ob_end_clean (); 
  
$size = strlen ($img); 
  
$FP 2 = fopen ($filename, "a"); 
  
Fwrite ($fp 2, $img); 
  
Fclose ($fp 2); 
  
return $filename; 
  
} 
  
Test 
  
Grabimage ("Yun_qi_img/logo.gif", "as.gif"); 
  
?> 
  
 
 
 
  
Ob_start: Turn on output buffering 
This function would turn output buffering on. While output buffering are active no output is sent from the script (other than headers), instead the "output is" stored in a n Internal buffer. (output is stored in the internal buffer) 
// 
ReadFile: Reads a file and writes to the output buffer 
Returns the number of bytes read from the file. If the error returns false and an error message is displayed unless invoked in the form of @readfile (). 
// 
 
Ob_get_contents:return the contents of the output buffer (returns the contents of the outputs buffered) 
This would return the contents of the output buffer without clearing it or FALSE, if output buffering isn ' t active. (FALSE if the output buffer is not active (open)) 
// 
Ob_end_clean (): Clean (erase) The output buffer and turn off output buffering (clear out buffer) 
This function discards (discards) the contents of the topmost output buffer and turns off this output buffering. (Discard and turn off) If you are want to further process the buffer ' s contents you have to call Ob_get_contents () before Ob_end_clean () as the Buffe R contents are discarded when Ob_end_clean () is called. (If you want to use buffered content, call Ob_get_contents ()) The function returns TRUE when it successfully discarded one buffer and FALSE o before scavenging the output buffer Therwise. Reasons for failure are-I-called the function without an active buffer or this for some reason a buffer could Not is deleted (possible for special buffer).