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!