Home  >  Article  >  Backend Development  >  怎么在请求头里添加自定属性

怎么在请求头里添加自定属性

WBOY
WBOYOriginal
2016-06-13 12:27:361126browse

如何在请求头里添加自定属性,
但需要在请求头里添加自定属性.例如 mimi=3322

如何定义这个?

$mimi = md5(3322);

$h = array("mimi:{$mimi}");
curl_setopt($ch,CURLOPT_HTTPHEADER,$h);
$result = curl_exec ($ch);


var_dump($result);


这样吗?可我测试来测试去,发送的请求都找不到自己定义的属性哦!~!~
------解决思路----------------------

<br />$url = 'http://www.example.com/server.php';<br />$mimi = md5(3322);<br /><br />$header = array(<br />    "mimi:{$mimi}"<br />);<br /><br />$ch = curl_init();<br />curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br />curl_setopt($ch, CURLOPT_URL, $url);<br />curl_setopt($ch, CURLOPT_HTTPHEADER, $header);<br />$response = curl_exec($ch);<br />if($error=curl_error($ch)){<br />    die($error);<br />}<br />curl_close($ch);<br /><br />echo $response;<br />


server.php
<br />$data = isset($_SERVER['HTTP_MIMI'])? $_SERVER['HTTP_MIMI'] : '';<br />echo $data;<br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn