function GrabImage($url,$filename) {
if($url==""):return false;endif; ob_start();
readfile($url);
$img = ob_get_contents();
ob_end_clean();
$size = strlen($img); //"../../images/books/"为存储目录,$filename为文件名
$fp2=@fopen("upfile/".$filename, "a");
fwrite($fp2,$img);
fclose($fp2); return $filename;
}
$filename=GrabImage("http://pic.111cn.net/enkj976.gif","11.jpg");
$men = new memcache();
// you can replace localhost by memcached server ip addr and port no.
$men->connect('localhost','11211');
$men->add("mystr","this is a test",MEMCACHE_COMPRESSED,3600);
$str=$men->get("mystr");
echo $str;