方法一:使用file_get_contents通过get方法获取内容:方法二:使用fopen打开url获取通过get方法Content:方法三:使用file_get_contents函数通过post获取url'bar');$data=http_build_query($data);$opts=array('http'=>array('method'=>'POST','header'=>'Content-type:application/x-www-form-urlencodedrn'.'Content-Length:'.strlen($data).'\r\n','content'=>$data));$context=stream_context_create($opts);$html=file_get_contents('https://wenda.shukaming.com',false,$context);echo$html;?>方法四:使用fsockopen函数打开url,获取完整的数据,包括header和body,在获取方式,fsockopen需要启用PHP.ini中的allow_url_fopen选项方法五:使用fsockopen函数打开url,通过POST获取完整的数据,包括header和body$value)$values[]="$key=".urlencode($value);$data_string=implode("t;&",$values);//找出需要哪个端口——如果没有给出使用standard(=80)if(!isset($URL_Info["port"]))$URL_Info["port"]=80;//buildingPOST-request:$request.="POST".$URL_Info["path"]."HTTP/1.1\n";$request.="Host:".$URL_Info["host"]."\n";$request.="Referer:$referer\n";$request.="Content-type:application/x-www-form-urlencodedn";$request.="Content-length:".strlen($data_string)."\n";$request.="Connection:close";$request.="Cookie:$cookie";$request.="\n";$request.=$data_string."\n";$fp=fsockopen($URL_Info["host"],$URL_Info["port"]);fputs($fp,$request);while(!feof($fp)){$result.=fgets($fp,1024);}fclose($fp);return$result;}?>方法六:使用curl库在使用curl库之前,可能需要检查php.ini中是否开启了curl扩展
