pg_port
PHP function
Edit on GitHub ✎
(PHP 4, PHP 5, PHP 7, PHP 8)
Return the port number associated with the connection
Description
pg_port(PgSql\Connection|null $connection = null): string
pg_port() returns the port number that the given PostgreSQL connection instance is connected to.
Parameters
connectionConnection-with-nullable-default
Return Values
A string containing the port number of the database server the connection is to, or empty string on error.
Changelog
| Version | Description |
|---|---|
| 8.0.0 | connection is now nullable. |
Examples
pg_port() example
php
<?php
$pgsql_conn = pg_connect("dbname=mark host=localhost");
if ($pgsql_conn) {
print "Successfully connected to port: " . pg_port($pgsql_conn) . "<br/>\n";
} else {
print pg_last_error($pgsql_conn);
exit;
}
?>