php的http协议怎么使用
1、采集远程文件/** * 采集远程文件 * * @access public * @param string $remote * 远程文件名 * @param string $local * 本地保存文件名 * @return mixed */ static public function curlDownload($remote, $local) { $cp = curl_init ( $remote ); $fp = fopen ( $local, "w" ); curl_setopt ( $cp, CURLOPT_FILE, $fp ); curl_setopt ( $cp, CURLOPT_HEADER, 0 ); curl_exec ( $cp ); curl_close ( $cp ); fclose ( $fp ); }



4、// 发送Http Header信息 开始下载 header ( "Pragma: public" ); header ( "Cache-control: max-age=" . $expire ); // header('Cache-Control: no-store, no-cache, must-revalidate'); header ( "Expires: " . gmdate ( "D, d M Y H:i:s", time () + $expire ) . "GMT" ); header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s", time () ) . "GMT" ); header ( "Content-Disposition: attachment; filename=" . $showname ); header ( "Content-Length: " . $length ); header ( "Content-type: " . $type ); header ( 'Content-Encoding: none' ); header ( "Content-Transfer-Encoding: binary" ); if ($content == '') { readfile ( $filename ); } else { echo ($content); } exit (); }
