php utf8_encode code example
Example 1: utf8 encode php
$a = "Não";
echo utf8_encode($a);
Example 2: php convert string to utf8
utf8_encode ( string $data )
Example 3: php set utf8 encoding
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
echo "Initial character set is: " . $mysqli -> character_set_name();
// Change character set to utf8
$mysqli -> set_charset("utf8");
echo "Current character set is: " . $mysqli -> character_set_name();
$mysqli -> close();
?>