MySQLi - Character Set Name
语法
string mysqli::character_set_name ( void )
定义和用法
它返回数据库连接的默认字符集。
示例
试试下面的例子 −
<?php $servername = "localhost:3306"; $username = "root"; $password = ""; $dbname = "TUTORIALS"; $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } echo "Database connected"; $charset = $conn->character_set_name(); printf ("Current character set is %s ", $charset); mysqli_close($conn); ?>
上述代码的示例输出应该是这样的 −
Database connected Current character set is latin1