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/03 Report--
This article mainly explains "PHP unified page coding to avoid garbled code", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "PHP unified page coding to avoid garbled"!
Uniform page coding
MySQL database coding, html page coding, PHP or html file coding itself to be consistent.
MySQL database code:
Specify the code (such as gbk_chinese_ci) when creating the database. Do not specify the code when creating the data table, creating the field, and inserting the data. The code of the database will be inherited automatically.
When connecting to the database, there is also a code, you can run mysql_query ('SET NAMES gbk') after connecting to the database;//replace gbk with your code, such as utf8.
2. The code of html page refers to the setting of this line:
The copy code is as follows:
3. Coding of PHP or html file itself:
Open php file or html file with editplus, save as, select encoding, if database and page encoding is gbk, then here encoding select ansi; if database and page encoding is utf-8, then here also select utf-8.
The data passed in Javascript or Flash is utf-8 encoded:
Also note that the data passed in Javascript or Flash is utf-8 encoded, if the database and page encoding is gbk, transcode and then write to the database.
The copy code is as follows:
iconv('utf-8', 'gbk', $content);
5. In PHP programs, you can add a line to specify the code of PHP source programs:
The copy code is as follows:
header('Content-type: text/html; charset=gbk');
php page coding
1. Set encoding in file header
The copy code is as follows:
Difference between header and meta
Use @header ('Content-type: text/html; charset= gbk'); to distinguish from
They all tell the browser what encoding to use to display the page. To say what is different, the header sends the original HTTP header, leaving nothing in the page, and the meta is written in the page.
First, if there is no meta in the page, sending HTTP headers works.
The second is to send the original HTTP header with the header() function, which can contain more content, and setting encoding is only one of them.
Third, sometimes don't show what the web page displays, but inform the browser what code to use for subsequent actions.
At this point, I believe that we have a deeper understanding of "PHP unified page coding to avoid garbled code," may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
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.