Code test connect to postgresql database by using PHP

error_reporting(E_ALL); ini_set(‘display_errors’, TRUE); ini_set(‘display_startup_errors’, TRUE); $host = “host = localhost”; $port = “port = 5432”; $dbname = “dbname = db_test”; $credentials = “user = root password = 123@123”; $db = pg_connect( “$host $port $dbname $credentials” ); if(!$db) { echo “Error : Unable to open database\n”; } else { echo “Opened database successfully\n”; }