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

藏色散人
Release: 2023-03-11 07:18:02
Original
2471 people have browsed it

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>";
Copy after login

Decoding after transmission

echo urldecode($_GET["name"]);
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!