برای mysqli
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
// Will NOT affect $mysqli->real_escape_string();
$mysqli->query("SET NAMES utf8");
// Will NOT affect $mysqli->real_escape_string();
$mysqli->query("SET CHARACTER SET utf8");
// But, this will affect $mysqli->real_escape_string();
$mysqli->set_charset('utf8');
// But, this will NOT affect it (utf-8 vs utf8) -- don't use dashes here
$mysqli->set_charset('utf-8');
?>
برای pdo
<?php
$pdo = new PDO("mysql:host=localhost;dbname=world;charset=utf 8", 'my_user', 'my_pass');
?>
در زمان طراحی پایگاه داده **collation خود پایگاه داده-جدول-فیلد- روی utf-8_general_ci قرار بدید
اینم درست کنید
<meta charset="UTF-8">