PHP mysqli_set_charset() Function

The mysqli_set_charset() function specifies the default character set to be used when sending data from and to the database server.

Object oriented style

bool mysqli::set_charset ( string $charset )

Procedural style

bool mysqli_set_charset ( mysqli $link , string $charset )

Sets the default character set to be used when sending data from and to the database server.

Examples -

Object oriented style

Procedural style

The above examples will output something similar to:

Initial character set: latin1
Current character set: utf8

ParameterDescription
linkProcedural style only: A link identifier returned by mysqli_connect() or mysqli_init()
charsetThe charset to be set as default.

Returns TRUE on success or FALSE on failure.