Avatar ·

UTF-8 all the way: how to configure PHP, MySQL and web server for correct work with Cyrillic and Unicode

Hi everyone! I'm a beginner PHP developer, and I'm already getting a headache from encoding issues. The site is written in PHP, the database is MySQL, the server is Apache. Everything seems to work, but as soon as a user enters Russian letters in a form, the nightmare begins: in the database, gibberish is saved like "Привет", and when displayed on the page — question marks or empty squares. I tried setting `` in the HTML head — it didn't help. I tried writing `header('Content-Type: text/html; charset=utf-8');` in PHP — that's not a cure-all either. In MySQL, the tables have `utf8_general_ci`, but the data still gets corrupted. Here's an example of my code: ```php