Home >Backend Development >PHP Problem >What to do if the value passed in php post is garbled

What to do if the value passed in php post is garbled

藏色散人
藏色散人Original
2021-07-02 09:17:542519browse

php Post value transmission garbled solution: 1. Encode before transmission and decode after transmission; 2. Use "iconv('UTF-8′,'GB18030′,$_GET["name "])" to decode.

What to do if the value passed in php post is garbled

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

What should I do if the php post value is garbled?

GET and POST Chinese transmission garbled characters in PHP

Method 1:

Encoding before transmission

 $ChineseName="我的名字,是中文的哦"; 
 $EncodeStr=urlencode($ChineseName); 
 echo "<a href=deal/dealLogin.php?name=$EncodeStr>我的名字</a>";

Decoding after transmission

echo urldecode($_GET["name"]);

Method 2:

Use iconv('UTF-8′,'GB18030′,$_GET["name"]) to decode

Recommended learning: "PHP Video Tutorial

The above is the detailed content of What to do if the value passed in php post is garbled. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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