The mysqli_get_charset() function returns a character set object.
PHP mysqli_get_charset() Function has the following syntax.
mysqli_get_charset(connection);
Parameter | Is Required | Description |
---|---|---|
connection | Required. | MySQL connection |
The returning character set object has the following properties.
Item | Meaning |
---|---|
charset | character set name |
collation | collation name |
dir | directory the charset was fetched from or "" |
min_length | min character length in bytes |
max_length | max character length in bytes |
number | internal character set number |
state | character set status |
The following code gets a character set object with its properties.
<?php//www . j av a2s .c o m
$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);
?>