Home > Backend Development > PHP Tutorial > Can CURLOPT_HTTPHEADER of php curl be customized? For example 'Request-Id' => '1w11'

Can CURLOPT_HTTPHEADER of php curl be customized? For example 'Request-Id' => '1w11'

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-08-04 09:21:11
Original
1296 people have browsed it

Can CURLOPT_HTTPHEADER of php curl be customized? For example, 'Request-Id' => '1w11', I did not receive it using $_SERVER

Reply content:

Can CURLOPT_HTTPHEADER of php curl be customized? For example, 'Request-Id' => '1w11', I did not receive it using $_SERVER

Yes, the format in the manual is not recommended

<code>CURLOPT_HTTPHEADER    设置 HTTP 头字段的数组。格式: array('Content-type: text/plain', 'Content-length: 100')

---
$head = array('Request-Id' => '1w11');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); </code>
Copy after login

It is recommended to put it directly in data

<code><?php

$ch = curl_init();

$data = array('Request-Id' => '1w11');

curl_setopt($ch, CURLOPT_URL, 'http://localhost/this.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_exec($ch);
?></code>
Copy after login

No. Can you tell me why you do this?

Just try it yourself and see if it works.
It should be possible. Google’s APIs are all there.
If it still doesn’t work, just build an http protocol format yourself and enable TCP transmission.

Related labels:
php
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template