PHP: Hypertext Preprocessor (original) (raw)

pg_client_encoding

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

pg_client_encoding — Gets the client encoding

Description

Note:

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

The function used to be called pg_clientencoding().

Parameters

connection

An PgSql\Connection instance. When connection is [null](reserved.constants.php#constant.null), the default connection is used. The default connection is the last connection made by pg_connect()or pg_pconnect().

Warning

As of PHP 8.1.0, using the default connection is deprecated.

Return Values

The client encoding.

Changelog

Version Description
8.1.0 The connection parameter expects an PgSql\Connection instance now; previously, a resource was expected.
8.0.0 connection is now nullable.

Examples

Example #1 pg_client_encoding() example

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

echo

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

The above example will output:

Client encoding is: ISO-8859-1

Found A Problem?

There are no user contributed notes for this page.