PHP Tutorial - PHP mysqli_get_charset() Function






Definition

The mysqli_get_charset() function returns a character set object.

Syntax

PHP mysqli_get_charset() Function has the following syntax.

mysqli_get_charset(connection);

Parameter

ParameterIs RequiredDescription
connectionRequired.MySQL connection

Return

The returning character set object has the following properties.
ItemMeaning
charsetcharacter set name
collationcollation name
dirdirectory the charset was fetched from or ""
min_lengthmin character length in bytes
max_lengthmax character length in bytes
numberinternal character set number
statecharacter set status




Example

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);
?>