In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about the solution to garbled echo get parameters in php. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Solutions to garbled php echo get parameters: 1, use "iconv (" gb2312 "," utf-8 ", $str);" Transcoding; 2, Transcoding through the mb_convert_encoding function.
This article operating environment: windows7 system, PHP7.4 version, DELL G3 computer
The cause and solution of garbled Chinese parameters in GET received by PHP
A few days ago, I wrote a search function with sphinx and tested the search results with a browser, but I couldn't find any Chinese content. I use echo to output the keyword $_ GET, which shows garbled code under the page code of UTF-8, which is normal when switching to gb2312. However, sphinx only supports Chinese character search in UTF-8, so I have to solve the problem of received Chinese parameters.
Under the google on the Internet, I found an article entitled "in-depth study of Chinese parameters garbled in PHP receiving GET". It was mentioned in the article that this is due to the setting problem of the browser. If you enter Chinese parameters directly on the address bar, the browsers in the Chinese interface generally receive the parameters with the code of gbk. In cases like this, we need to use php's built-in transcoding function to deal with the coding problem:
Option 1:
$str = iconv ("gb2312", "utf-8", $str)
Option 2:
Mb_convert_encoding ($str, "utf-8", "gb2312")
If the Chinese parameter is obtained by using the text input box under the page encoding of utf-8, the page will encode it by default, so the above transcoding method is not needed in this case.
If you want to generate a link with Chinese parameter values on the page, you need to encode the Chinese characters with urlencode () under the utf-8-encoded code and then generate the link.
Thank you for reading! This is the end of this article on "the solution to the garbled echo get parameters in php". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.