uTools-Manuals/docs/php/mysql_set_charset.html
2019-04-28 19:00:34 +08:00

115 lines
4.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>设置客户端的字符集</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.mysql-set-charset" class="refentry">
<div class="refnamediv">
<h1 class="refname">mysql_set_charset</h1>
<p class="verinfo">(PHP 5 &gt;= 5.2.3)</p><p class="refpurpose"><span class="refname">mysql_set_charset</span> &mdash; <span class="dc-title">设置客户端的字符集</span></p>
</div>
<div id="function.mysql-set-charset-soft-deprecation-notice" class="soft-deprecation-notice">
<blockquote class="sidebar">
<p class="para">本扩展自 PHP 5.5.0
起已废弃,并在自 PHP 7.0.0 开始被移除。应使用 <a href="book.mysqli.html" class="link">MySQLi</a>
<a href="ref.pdo_mysql.html" class="link">PDO_MySQL</a> 扩展来替换之。参见
<a href="mysqlinfo.api.choosing.html" class="link">MySQL选择 API</a> 指南以及<a href="faq.databases.html#faq.databases.mysql.deprecated" class="link">相关 FAQ</a> 来获取更多信息。用以替代本函数的有:</p>
<ul class="simplelist">
<li class="member"><span class="function"><a href="mysqli.character_set_name.html" class="function">mysqli_character_set_name()</a></span></li>
<li class="member">PDO: 添加 <em>charset</em> 到连接字符串,比如 <em>charset=utf8</em></li>
</ul>
</blockquote>
</div>
<div class="refsect1 description" id="refsect1-function.mysql-set-charset-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>mysql_set_charset</strong></span>
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$charset</code></span>
[, <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code><span class="initializer"> = NULL</span></span>
] ) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
设置当前连接的默认字符集。
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.mysql-set-charset-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">charset</code></dt>
<dd>
<p class="para">
一个有效的字符集名称。
</p>
</dd>
<dt>
<code class="parameter">
link_identifier</code></dt>
<dd>
<p class="para">MySQL
连接。如不指定连接标识,则使用由 <span class="function"><a href="mysql_connect.html" class="function">mysql_connect()</a></span>
最近打开的连接。如果没有找到该连接,会尝试不带参数调用
<span class="function"><a href="mysql_connect.html" class="function">mysql_connect()</a></span>
来创建。如没有找到连接或无法建立连接,则会生成
<strong><code>E_WARNING</code></strong> 级别的错误。</p></dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.mysql-set-charset-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 notes" id="refsect1-function.mysql-set-charset-notes">
<h3 class="title">注释</h3>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
本函数需要 MySQL 5.0.7 或更高版本。
</p>
</p></blockquote>
<blockquote class="note"><p><strong class="note">Note</strong>:
<p class="para">
这是改变字符集的最佳方式。不推荐您使用
<span class="function"><a href="mysql_query.html" class="function">mysql_query()</a></span> 来设置 (比如 <em>SET NAMES utf8</em>)。
更多信息参见 <a href="mysqlinfo.concepts.charset.html" class="link">MySQL character set concepts</a>
一节。
</p>
</p></blockquote>
</div>
<div class="refsect1 seealso" id="refsect1-function.mysql-set-charset-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="mysql_client_encoding.html" class="function" rel="rdfs-seeAlso">mysql_client_encoding()</a> - 返回字符集的名称</span></li>
<li class="member"><a href="mysqlinfo.concepts.charset.html" class="link">Setting character sets in MySQL</a></li>
<li class="member"><a href="http://dev.mysql.com/doc/mysql/en/charset_charsets.html" class="link external">&raquo;&nbsp;List of character sets that MySQL supports</a></li>
</ul>
</p>
</div>
</div></div></div></body></html>