您好,欢迎访问一九零五行业门户网

PHP发送请求头和接收打印请求头

php发送请求头和接收打印请求头
一、发送请求头
//发送地址 $url = 'http://127.0.0.1/2.php'; //请求头内容 $headers = array( 'authorization: '.$basic, 'suibianzhi: '.$basic, ); //使用curl发送 $ch = curl_init($url); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_ssl_verifypeer, false); curl_setopt($ch, curlopt_ssl_verifyhost, false); curl_setopt($ch, curlopt_httpheader, $headers); $result = curl_exec($ch); curl_close($ch); echo $result;
二、接收并打印请求头
$headers = array(); foreach ($_server as $key => $value) { if ('http_' == substr($key, 0, 5)) { $headers[str_replace('_', '-', substr($key, 5))] = $value; } } echo ''; print_r($headers);
其它类似信息

推荐信息