PHP mysqli_get_charset() Function

PHP mysqli_get_charset() function returns a character set object providing several properties of the current active character set.


object mysqli_get_charset(connection);

mysqli_get_charset() Function Parameter

Connection :Required parameter. The MySQL connection to be used.

mysqli_get_charset() Function Return Value

Return Values :Returns a character set object with the following properties:

  • charset - character set name
  • collation - collation name
  • dir - directory the charset description was fetched from (?) or "" for built-in character sets
  • min_length - min character length in bytes
  • max_length - max character length in bytes
  • number - internal character set number
  • state - character set status

mysqli_get_charset() Function Example

$con = mysqli_get_charset("localhost","user","password","db");

if (mysqli_connect_errno())
	echo "Failed to connect to MySQL: " . mysqli_connect_error();