About PHP http message settings CURLOPT_HTTPHEADER

藏色散人
Release: 2023-04-08 16:28:02
forward
6071 people have browsed it

About PHP http message settings CURLOPT_HTTPHEADER

The trap set by PHP CURLOPT_HTTPHEADER

No more nonsense, just go to the code

//省略。。。
curl_setopt($ci, CURLOPT_HTTPHEADER, $headers);
//省略。。。
Copy after login

us The $headers are usually written like this

//错误示范 二维数组
$headers = [
    "Content-Type"     => "application/json",
    "X-Requested-With" => "XMLHttpRequest",
];
//正确写法
$headers = [
    "Content-Type:application/json",
    "X-Requested-With:XMLHttpRequest",
];
Copy after login

I was stuck by this small problem for more than 2 hours. I hope it can help friends who use PHP cURL to troubleshoot

Recommendation: " PHP video tutorial

The above is the detailed content of About PHP http message settings CURLOPT_HTTPHEADER. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:learnku.com
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template