เพิ่งรู้ว่ามีความแตกต่างระหว่าง set names , set charecter set และ set_charset()


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<?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');
?>

reference : http://php.net/manual/en/mysqlinfo.concepts.charset.php

แสดงความคิดเห็น

0 ความคิดเห็น