php8.5
Home/ Manual/ mysql / functions/ mysql_set_charset

mysql_set_charset

PHP function Edit on GitHub ✎

(PHP 5 >= 5.2.3)

Sets the client character set

Note mysqli_set_charsetPDO: Add charset to the connection string, such as charset=utf8

Description

mysql_set_charset(string $charset, resource $link_identifier = NULL): bool

Sets the default character set for the current connection.

Parameters

charset

A valid character set name.

Return Values

Success

Notes

Note

This function requires MySQL 5.0.7 or later.

Note

This is the preferred way to change the charset. Using mysql_query() to set it (such as SET NAMES utf8) is not recommended. See the MySQL character set concepts section for more information.

See Also

Source: reference/mysql/functions/mysql-set-charset.xml · from the official PHP manual (php/doc-en)