[PHP MyAdmin, Apache] The server has the utf8_general_ci encoding, in the php UTF-8 editor, the local storage is displayed on the local computer. What is the reason? All tables are also in the correct encoding.

<?php $connection = mysqli_connect ('127.0.0.1', 'root', '', 'test_db'); if( $connection == false ) { echo 'Не удалось подключиться к базе данных!<br>'; echo mysqli_connect_error(); exit(); } else { echo 'Работает подключение'; } ?> 

enter image description here enter image description here

  • one
    This has been discussed many times, check for a start BOM - Vladimir Klykov
  • I will try to find and understand - Andryukha Kiev
  • ru.wikipedia.org/wiki/Marker_sequence_bytes if it is not it - SET NAMES UTF-8 - Vladimir Klykov

2 answers 2

 $connection = mysqli_connect ('127.0.0.1', 'root', '', 'test_db'); $connection->set_charset("utf8"); 

Plus in the given page should be specified:

 <meta charset="utf-8" /> 

Also in php.ini should install

 default_charset="UTF-8" 

    Encoding must be UTF-8 without BOM

    • For some reason, it works for me with BOM, but without BOM there isn’t. - Andryukha Kiev