curl配置host
//要配置的虚拟域名
$host = array( 'Host: demo-local.com' );
$ch = curl_init();
//要配置的ip 例如本机localhost
curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:80/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch,CURLOPT_HTTPHEADER, $host );
$ret = curl_exec($ch);
$errno=curl_errno($ch);
if( $errno ){
echo $errno.'#'.curl_error($ch);
}else{
echo 'curl return:<br/>';
echo '----------<br/>';
var_dump($ret);
echo '----------<br/>';
}
curl_close($ch);
posted on 2017-05-22 16:09 dongruiha 阅读(3121) 评论(0) 编辑 收藏 举报