php - How can I view the result of pg_escape_literal?

one text

Solution:

The issue was a silly mistake, which was pointed out by Chris Haas in a comment, which was later removed.

When using pg_escape_string, one can omit the first argument, which is the connection to the database, for it to seem like it's working in my situation. I do not know if it is working properly in all cases and my guess is no, but it seems like it's working.

When using pg_escape_literal, the connection appears to be somewhat necessary, and the function returned an empty string without a connection argument. However, the following code

<?php
    $conn = pg_connect("/* login details */");
    $escaped = pg_escape_literal($conn, 'Hello world!');
    pg_close($conn);
    echo "Escaped: '".$escaped."'";
?>

produces the following output, which seems to be... well... at least not empty, to say the least.

Escaped: ''Hello world!''

It also appears to work if I connect to any database at all, without necessarily specifying the connection in pg_escape_literal.

Thanks a bunch to Chris Haas for the clue.

Source