Home  >  Article  >  Backend Development  >  How to set the encoding of mysql to utf-8 in php

How to set the encoding of mysql to utf-8 in php

藏色散人
藏色散人Original
2020-09-07 10:21:403741browse

php method to set the encoding of mysql to utf-8: first use the editor to open the my.ini configuration file; then add the configuration [character-set-server=utf8]. You can also set the encoding when connecting to the database through the mysqli_set_charset() function.

How to set the encoding of mysql to utf-8 in php

Recommendation: "php video tutorial"

Both methods can be used:

1. In the my.ini file, be sure to restart after setting up


2. When connecting to the database, the code here must be in the database Before writing the query, you must pass in the connection object and encoding



Finally, you can read it in the browser Chinese


The above is the detailed content of How to set the encoding of mysql to utf-8 in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn