In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you how to code garbled in the database, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
1. Use tags to set page encoding
2. Header ("content-type:text/html; charset=xxx")
Header ("content-type:text/html; charset=xxx")
AddDefaultCharset xxx
If you are a web programmer, add a header ("content-type:text/html; charset=xxx") to each of your pages
Ensure that it can be displayed correctly on any server and is highly portable.
Uniform coding of PHP pages
MySQL database encoding, html page encoding, PHP or html file itself encoding should all be consistent.
1. MySQL database coding: specify a code (such as gbk_chinese_ci) when establishing a database, and do not specify a code when establishing data tables, fields, and inserting data, which will automatically inherit the coding of the database.
When connecting to the database, there is also coding, which can be executed after connecting to the database.
Mysql_query ('SET NAMES utf-8'); / / replace gbk with your code, such as utf8.
2. The encoding of the html page refers to the setting of this line:
3, PHP or html file itself encoding: use editplus to open the php file or html file, save, the choice of encoding, if the database and page code is gbk, then here the encoding choice ansi; if the database and page code is utf-8, then here also choose utf-8.
4. In addition, it should be noted that the data passed in Javascript or Flash is utf-8 encoding. If the database and page code is gbk, transcode it and then write it to the database.
Iconv ('utf-8',' gbk', $content)
5. In the PHP program, you can add a line to specify the encoding of the PHP source program:
Header ('Content-type: text/html; charset=utf-8')
The above is all the contents of the article "how to code garbled in the database". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.