php8.5
Home/ Manual/ pgsql / functions/ pg_version

pg_version

PHP function Edit on GitHub ✎

(PHP 5, PHP 7, PHP 8)

Returns an array with client, protocol and server version (when available)

Description

pg_version(PgSql\Connection|null $connection = null): array

pg_version() returns an array with the client, protocol and server version.

For more detailed server information, use pg_parameter_status().

Parameters

connection

Connection-with-nullable-default

Return Values

Returns an array with client, protocol and server keys and values (if available).

Changelog

VersionDescription
8.0.0connection is now nullable.

Examples

pg_version() example

php
<?php
  $dbconn = pg_connect("host=localhost port=5432 dbname=mary")
     or die("Could not connect");
     
  $v = pg_version($dbconn);
  
  echo $v['client'];
?>

The above example will output:

output
7.4

See Also

Source: reference/pgsql/functions/pg-version.xml · from the official PHP manual (php/doc-en)