Home  >  Article  >  Backend Development  >  About PHP http message settings CURLOPT_HTTPHEADER

About PHP http message settings CURLOPT_HTTPHEADER

藏色散人
藏色散人forward
2020-05-10 14:00:135896browse

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);
//省略。。。

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",
];

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!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete