Solution to the garbled problem of web pages when the encoding is set to utf-8

Solution to the garbled problem of web pages when the encoding is set to utf-8
Recently, when I was writing web pages with PHP, I set the encoding to UTF-8. But the disgusting thing was that garbled characters appeared many times, which gave me a headache. I finally took 10 minutes to find out the root cause of the garbled characters from the Internet. From now on, I am not afraid of garbled characters on web pages anymore, haha! !

UTF-8 is an international encoding, including Chinese characters. It is recommended to set it to UTF-8 to save trouble;

The steps are as follows:

First: define the web page display code. If the web page encoding is not defined, IE will automatically identify the web page encoding when we browse the web page, which may cause garbled Chinese characters to be displayed. Therefore, when we make web pages, we always use “<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>” to define the web page encoding.

Second: Web page storage encoding. People often overlook this issue. When we edit a web page, different tools will use a default encoding format. We should edit and save it in utf-8 format, and use <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> to make the web page display encoding utf8. If it is inconsistent, it will cause garbled characters.

ps: When PHP programming uses a database, the database encoding must also be consistent with the encoding displayed on the web page, so that the database content can be displayed on the web page without garbled characters;

Thanks!

<<:  Introduction to the process of installing MySQL 8.0 in Linux environment

>>:  A brief discussion on the placement of script in HTML

Recommend

Do you know how to use the flash wmode attribute in web pages?

When doing web development, you may encounter the...

Ubuntu16.04 installation mysql5.7.22 graphic tutorial

VMware12.0+Ubuntu16.04+MySQL5.7.22 installation t...

How to use css variables in JS

How to use css variables in JS Use the :export ke...

Solution to the problem of MySQL thread in Opening tables

Problem Description Recently, there was a MySQL5....

Mysql sorting and paging (order by & limit) and existing pitfalls

Sorting query (order by) In e-commerce: We want t...

Computed properties and listeners details

Table of contents 1. Calculated properties 1.1 Ba...

Detailed explanation of fuser command usage in Linux

describe: fuser can show which program is current...

Our thoughts on the UI engineer career

I have been depressed for a long time, why? Some t...

MySQL Series 7 MySQL Storage Engine

1. MyISAM storage engine shortcoming: No support ...

Table Tag (table) In-depth

<br />Table is a tag that has been used by e...

vue+tp5 realizes simple login function

This article example shares the specific code of ...

The most comprehensive explanation of the locking mechanism in MySQL

Table of contents Preface Global Lock Full databa...

JavaScript implements mouse drag to adjust div size

This article shares the specific code of JavaScri...

Common naming rules for CSS classes and ids

Public name of the page: #wrapper - - The outer e...