array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.pg-client-encoding.php', 1 => 'pg_client_encoding', ), 'up' => array ( 0 => 'ref.pgsql.php', 1 => 'PostgreSQL 函数', ), 'prev' => array ( 0 => 'function.pg-cancel-query.php', 1 => 'pg_cancel_query', ), 'next' => array ( 0 => 'function.pg-close.php', 1 => 'pg_close', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/pgsql/functions/pg-client-encoding.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8)
pg_client_encoding — 获取客户端编码
PostgreSQL 支持某些字符集在服务器和客户端之间自动进行字符集转换。pg_client_encoding() 以字符串形式返回客户端编码。返回的字符串将是标准的 PostgreSQL 编码标识符之一。
注意:
此函数需要 PostgreSQL 7.0 或更高版本。如果 libpq 在没有多字节编码支持的情况下编译,pg_client_encoding() 总是返回
SQL_ASCII
。支持的编码取决于 PostgreSQL 版本。请参阅 PostgreSQL 文档支持的编码。此函数过去称为 pg_clientencoding()。
connection
An PgSql\Connection instance.
When connection
is null
, the default connection is used.
The default connection is the last connection made by pg_connect()
or pg_pconnect().
As of PHP 8.1.0, using the default connection is deprecated.
客户端编码。
版本 | 说明 |
---|---|
8.1.0 |
现在 connection 参数接受 PgSql\Connection
实例,之前接受 resource。
|
8.0.0 |
connection 现在可以为 null。
|
示例 #1 pg_client_encoding() 示例
<?php
// Assume $conn is a connection to a ISO-8859-1 database
$encoding = pg_client_encoding($conn);
echo "Client encoding is: ", $encoding, "\n";
?>
以上示例会输出:
Client encoding is: ISO-8859-1