curl 解析到特定的ip地址

curl在7.46.0版本中添加了一个新的属性:CURLOPT_CONNECT_TO,能够设置host对应的ip地址和端口,而不用去手工修改系统的host配置。php

php语言,从php7.0.7版本开始支持此项功能。php7

php示例(使用guzzlehttp):curl

$options = array(
			'curl' => array(
				CURLOPT_CONNECT_TO => ["{$baiduhost}:80:{$realhost}:80"],
			),
		);

	$client = new \GuzzleHttp\Client($options);
相关文章
相关标签/搜索