Where are the coding methods to be noted?

Source: Internet
Author: User
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
......

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.