Home > Article > Backend Development > How to set the encoding of mysql to utf-8 in php
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.
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!