PHP mysqli_character_set_name() 函数
2018-12-08 16:53 更新
PHP mysqli_character_set_name() 函数
实例
返回数据库连接的默认字符集:
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$charset=mysqli_character_set_name($con);
echo "Default character set is: " . $charset;
mysqli_close($con);
?>
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$charset=mysqli_character_set_name($con);
echo "Default character set is: " . $charset;
mysqli_close($con);
?>
定义和用法
mysqli_character_set_name() 函数返回数据库连接的默认字符集。
语法
mysqli_character_set_name(connection);
参数 | 描述 |
---|---|
connection | 必需。规定要使用的 MySQL 连接。 |
技术细节
返回值: | 指定连接的默认字符集。 |
---|---|
PHP 版本: | 5+ |
PHP MySQLi 参考手册
以上内容是否对您有帮助:
更多建议: