(PHP 3, PHP 4 >= 4.0.0)
pg_port() will return the port number that the given PostgreSQL connection identifier is connected to.