MySQLi - Get Charset



Syntax

object mysqli_get_charset ( mysqli $link )

Definition and Usage

It returns a character set object.

Example

Try out following example −

<?php
   $db = mysqli_init();
   $servername = "localhost:3306";
   $username = "root";
   $password = "";
   $dbname = "TUTORIALS";

   $conn = mysqli_real_connect($db,$servername, $username, $password, $dbname);
   var_dump(mysqli_get_charset($db));
?>

The sample output of the above code should be like this −

object(stdClass)#2 (8) { 
   ["charset"]=> string(6) "latin1" ["collation"]=> string(17) "latin1_swedish_ci" 
   ["dir"]=> string(0) "" ["min_length"]=> int(1) ["max_length"]=> int(1) 
   ["number"]=> int(8) ["state"]=> int(1) ["comment"]=> string(0) "" 
}
mysqli_useful_functions.htm
Advertisements