1<?php
2$mysqli = new mysqli("localhost","my_user","my_password","my_db");
3
4if ($mysqli -> connect_errno) {
5 echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
6 exit();
7}
8
9echo "Initial character set is: " . $mysqli -> character_set_name();
10
11// Change character set to utf8
12$mysqli -> set_charset("utf8");
13
14echo "Current character set is: " . $mysqli -> character_set_name();
15
16$mysqli -> close();
17?>