The second example (Displaying the Oracle error message after a parsing error) is wrong.
This example works for me:
$stmt = @oci_parse($conn, "select ' from dual"); // note mismatched quote
if (!$stmt) {
$e = oci_error($conn); // For oci_parse errors pass the connection handle
echo htmlentities($e['message']);
}