Problems related to the loss of Php request parameters and Chinese garbled characters

Source: Internet
Author: User
Question about the loss of Php request parameters and Chinese garbled characters ??? Recently, due to the needs of the open platform project, I encountered some problems when writing the php sdk. I made a mark to avoid missing the question ??? The request parameters sent by Php are missing :? Curl_setopt ($ ch, CURLOPT_POSTFIELDS, Php request parameter loss and Chinese garbled characters

? ? ? Recently, due to the needs of the open platform project, I encountered some problems when writing the php sdk, so as not to forget it later.

?

? ? The request parameters sent by Php are missing:

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

? $ Reponse = curl_exec ($ ch );

? After the request arrives at the server, the postBodyString content does not appear in the request and the parameter is lost.

?

? ? Solution:

? ? Use the Header to perform the following settings:

? ? $ Headers = array ('Content-type: application/x-www-form-Urlencoded; Charset = UTF-8');?

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

?

? ? In addition, if the returned results contain Chinese characters and garbled characters, you can use the above method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.