Php 检查特定卷曲选项的返回值
我想检查Php 检查特定卷曲选项的返回值,php,curl,Php,Curl,我想检查CURLOPT\u DNS\u服务器选项的返回值。我使用PHP5.5.20并添加了此选项。这是我的代码 function do_web_request($url) { $dns_array = array("8.8.8.8","209.244.0.3","84.200.69.80","84.200.69.80","8.26.56.26","208.67.222.222","156.154.70.1","199.85.126.10","81.218.119.11","195.46.3
CURLOPT\u DNS\u服务器
选项的返回值。我使用PHP5.5.20
并添加了此选项。这是我的代码
function do_web_request($url)
{
$dns_array = array("8.8.8.8","209.244.0.3","84.200.69.80","84.200.69.80","8.26.56.26","208.67.222.222","156.154.70.1","199.85.126.10","81.218.119.11","195.46.39.39","107.150.40.234","208.76.50.50","216.146.35.35","37.235.1.174","89.233.43.71");
$randomDNS = $dns_array[array_rand($dns_array, 1)];
/* initializing curl */
$curl_handle = curl_init($url);
/* set this option the curl_exec function return the response */
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
/* follow the redirection */
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_handle, CURLOPT_DNS_SERVERS , $randomDNS);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT , 5);
/* invoke the request */
$response = curl_exec($curl_handle);
/* cleanup curl stuff */
curl_close($curl_handle);
return $response;
}
您可以获取标题和所有详细信息:
$skip = intval(curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE));
$header = substr($response,0,$skip);
$result= curl_getinfo($curl_handle);
$result['header'] = $header;
$data
m在此未定义。是我的一个脚本的副本,其中我使用$data,而您使用$response。将$data替换为您的$response,并将我的$response更改为$result(2x)。
$skip = intval(curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE));
$header = substr($response,0,$skip);
$result= curl_getinfo($curl_handle);
$result['header'] = $header;