码迷,mamicode.com
首页 > 数据库 > 详细

debug $mysqli->character_set_name();

时间:2016-09-10 16:01:13      阅读:227      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!