php mysqli_get_charset()函数

时间:2017-03-02
php mysqli_get_charset()函数返回一个字符集对象。 本文章向大家介绍mysqli_get_charset()函数的基本语法和使用实例,需要的朋友可以参考一下。

定义

mysqli_get_charset()函数返回一个字符集对象。

语法

PHP mysqli_get_charset()函数具有以下语法。

mysqli_get_charset(connection);

参数

参数 是否必须 描述
connection 需要。 MySQL连接

返回值

The returning character set object has the following properties. 返回一个字符集对象

项目 含义
charset 字符集名称
collation 排序规则名称
dir 从中获取字符集的目录或“”
min_length min字符长度,以字节为单位
max_length 最大字符长度(以字节为单位)
number 内部字符集编号
state 字符集状态

实例

以下代码使用其属性获取字符集对象。

<?php
//  http://www.manongjc.com/article/1669.html
//  作者:码农教程
$con=mysqli_connect("localhost","my_user","my_password","my_db");

if (mysqli_connect_errno($con)){
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

var_dump(mysqli_get_charset($con));

mysqli_close($con);
?>