Home > Backend Development > PHP Tutorial > Php发送请求参数丢失有关问题以及中文乱码有关问题

Php发送请求参数丢失有关问题以及中文乱码有关问题

WBOY
Release: 2016-06-13 11:17:53
Original
1039 people have browsed it

Php发送请求参数丢失问题以及中文乱码问题

? ? ?最近由于开放平台项目的需要,在写php版的sdk,过程中碰到一些问题,做个记号,以免后面忘记

?

? ? Php发送请求参数丢失:

? curl_setopt($ch, CURLOPT_POSTFIELDS, substr($postBodyString, 0, -1));

? $reponse = curl_exec($ch);

? 发现请求到达服务端后,postBodyString的内容并没有出现在请求里,参数丢失

?

? ?解决方法:

? ?使用Header进行以下设置:

? ?$headers = array('content-type: application/x-www-form-urlencoded;charset=UTF-8');?

???curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

?

? ?另外,返回结果里如果有中文,出现乱码,则也可以采用上面的方法解决。

Related labels:
source:php.cn
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