Latest web development tutorials

PHP mysqli_character_set_name () function

PHP MySQLi Reference Manual PHP MySQLi Reference Manual

Examples

Returns the default character set of the database connection:

<? php
$ con = mysqli_connect ( "localhost" , "my_user", "my_password", "my_db");

// Check the connection
if (mysqli_connect_errno ($ con))
{
echo "Database connection failed:" mysqli_connect_error ();.
}

$ charset = mysqli_character_set_name ($ con) ;
echo "The default character set is:" $ charset;.

mysqli_close ($ con);
?>

Definition and Usage

mysqli_character_set_name () function returns the default character set of the database connection.


grammar

mysqli_character_set_name( connection ) ;

参数 描述
connection 必需。规定要使用的 MySQL 连接。

technical details

return value: Specifies the default character set of the connection.
PHP version: 5+


PHP MySQLi Reference Manual PHP MySQLi Reference Manual