Having been exposed to such a long time web design has come across a lot of things related to coding. But today again encountered a garbled, fortunately search to solve.
Here are some of the places I know to be aware of coding:
1.
(Notifies the browser how this page is decoded)
2.
How the document is encoded when it is saved
3.
How the database is encoded (set when defining a database or table)
4.
How SQL statements are encoded (using the Set NAMES UTF8 setting)
What is the final coding method? In this case:
A static page data from a text data frame is transferred to another PHP page via the Get method, and this PHP page puts the data into an INSERT statement and executes the SQL statement.
What is the decision to encode this query statement at this point? Is it a static page encoding or a dynamic page encoding or something else? Anyway I was all set into UTF-8, successfully inserted, no garbled. But the problem is that you use the Set NAMES UTF8 setting for each insert, how can I set the UTF8 to the default encoding for SQL statements?
Where else do you need to pay attention to coding?
Reply to discussion (solution)
All "encodings" are based on the output page
MySQL has an adaptive "encode" function (other databases are unclear), that is, what encoding does he return when you let him return?
The principle is: almost every IO should consider the coding problem
Loading PHP itself is one time because the system/web server and PHP itself are two encodings
PHP output, client system/browser and output characters are two encoded
Read and write files, read and write databases, include ... Wait a minute
A few more easily overlooked
Cookies, this is not a very small chance, but be aware
Session, I did not test two different coded PHP common use a session case, you try
Send receive, such as curl, socket, and API
Interacting with other languages
......