首页 > 数据库技术 > 详细

debug $mysqli->character_set_name();

时间:2016-09-10 16:00:08      阅读:317      评论:0      收藏:0      [点我收藏+]

 

<?php
$mysqli = new mysqli(‘localhost‘, ‘root‘, ‘‘, ‘w‘);
if(mysqli_connect_errno()){
    printf(‘Connect failed: %s\n‘, mysqli_connect_errno());
    exit();
}

$charset = $mysqli->character_set_name(); //Initial character set //latin1
//Sets the default character set to be used when sending data from and to the database server. BOOL
if($charset !== ‘utf8‘) $mysqli->set_charset(‘utf8‘);
$charset = $mysqli->character_set_name(); //Current character set //utf8

 

<?php
$mysqli = new mysqli(‘localhost‘, ‘root‘, ‘‘, ‘w‘);
if(mysqli_connect_errno()){
    printf(‘Connect failed: %s\n‘, mysqli_connect_errno());
    exit();
}

if(!$mysqli->set_charset(‘utf8‘))echo $mysqli->error;
if(!$mysqli->set_charset(‘2utf8‘))echo $mysqli->error; //Invalid characterset or character set not supported
if(!$mysqli->set_charset(‘utf-8‘))echo $mysqli->error; //Invalid characterset or character set not supported
if(!$mysqli->set_charset(‘UTF-8‘))echo $mysqli->error; //Invalid characterset or character set not supported

 

debug $mysqli->character_set_name();

原文:http://www.cnblogs.com/yuanjiangw/p/5859528.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!