I had to debug a rather large piece of PHP code today, and discovered a bunch of weird behaviors:
First of all, if the pgsql.so PHP plugin is not loaded and PostgreSQL functions are called, PHP does not produce any errors, it just fails silently.
Then, pg_connect may fail. This, of course, generates error messages. These error messages can be retrieved by calling pg_last_error() after pg_connect(). This produced the following output:
Could not connect:
Ah, so that's why.