当前位置:Gxlcms > 数据库问题 > debug $mysqli->character_set_name();

debug $mysqli->character_set_name();

时间:2021-07-01 10:21:17 帮助过:8人阅读

$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();

标签:

人气教程排行