PHP 8.3.4 Released!

pg_client_encoding

(PHP 4 >= 4.0.3, PHP 5, PHP 7, PHP 8)

pg_client_encoding Gets the client encoding

Descrição

pg_client_encoding(?PgSql\Connection $connection = null): string

PostgreSQL supports automatic character set conversion between server and client for certain character sets. pg_client_encoding() returns the client encoding as a string. The returned string will be one of the standard PostgreSQL encoding identifiers.

Nota:

This function requires PostgreSQL 7.0 or higher. If libpq is compiled without multibyte encoding support, pg_client_encoding() always returns SQL_ASCII. Supported encoding depends on PostgreSQL version. Refer to the PostgreSQL Documentation supported encodings.

The function used to be called pg_clientencoding().

Parâmetros

connection

Uma instância de PgSql\Connection. Quando o parâmetro connection for null, a conexão padrão será usada. A conexão padrão é a última conexão feita por pg_connect() ou pg_pconnect().

Aviso

A partir do PHP 8.1.0, usar a conexão padrão tornou-se defasado.

Valor Retornado

The client encoding.

Registro de Alterações

Versão Descrição
8.1.0 O parâmetro connection agora espera uma instância de PgSql\Connection; anteriormente, um resource era esperado.
8.0.0 connection is now nullable.

Exemplos

Exemplo #1 pg_client_encoding() example

<?php
// Assume $conn is a connection to a ISO-8859-1 database
$encoding = pg_client_encoding($conn);

echo
"Client encoding is: ", $encoding, "\n";
?>

O exemplo acima produzirá:

Client encoding is: ISO-8859-1

Veja Também

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top