array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.mysql-set-charset.php', 1 => 'mysql_set_charset', ), 'up' => array ( 0 => 'ref.mysql.php', 1 => 'MySQL 函数', ), 'prev' => array ( 0 => 'function.mysql-select-db.php', 1 => 'mysql_select_db', ), 'next' => array ( 0 => 'function.mysql-stat.php', 1 => 'mysql_stat', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/mysql/functions/mysql-set-charset.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.2.3)
mysql_set_charset — 设置客户端的字符集
本扩展自 PHP 5.5.0 起已废弃,并在自 PHP 7.0.0 开始被移除。应使用 MySQLi 或 PDO_MySQL 扩展来替换之。参见 MySQL:选择 API 指南来获取更多信息。用以替代本函数的有:
charset
到连接字符串,比如 charset=utf8
charset
一个有效的字符集名称。
link_identifier
MySQL
连接。如不指定连接标识,则使用由 mysql_connect()
最近打开的连接。如果没有找到该连接,会尝试不带参数调用
mysql_connect()
来创建。如没有找到连接或无法建立连接,则会生成
E_WARNING
级别的错误。
注意:
本函数需要 MySQL 5.0.7 或更高版本。
注意:
这是改变字符集的最佳方式。不推荐您使用 mysql_query() 来设置 (比如
SET NAMES utf8
)。 更多信息参见 MySQL character set concepts 一节。