如何将所有PHP Oracle错误函数放在一个函数中?

如何将所有PHP Oracle错误函数放在一个函数中?,php,oracle,Php,Oracle,我尝试构建一个函数来保存所有错误 以下是我的例子: <?php $stid = oci_parse($conn, "select does_not_exist from dual"); $r = oci_execute($stid); if (!$r) { $e = oci_error($stid); // For oci_execute errors pass the statement handle print htmlentities($e['message']);

我尝试构建一个函数来保存所有错误 以下是我的例子:

<?php
$stid = oci_parse($conn, "select does_not_exist from dual");
$r = oci_execute($stid);
if (!$r) {
    $e = oci_error($stid);  // For oci_execute errors pass the statement handle
    print htmlentities($e['message']);
    print "\n<pre>\n";
    print htmlentities($e['sqltext']);
    printf("\n%".($e['offset']+1)."s", "^");
    print  "\n</pre>\n";
}
?>
} 我想这样做

但它不起作用uu请帮助执行此操作

oci_u错误应该在连接上运行,从变量名看不清楚解析是什么。这似乎是个问题。

function error($r, $stid){
    if(!$r){
        $error = oci_error($stid);
        $code = "Code"." ".$error["code"];
        $sql = "Sql Statment"." ".$error["sqltext"];
        $Position = "Position"." ".$error["offset"];
        $message = "Message"." ".$error["message"];
        $all = array("code"=>$code, "sql"=>$sql, "Position"=>$Position, "message"=>$message);
            return($all);
        }   
$stid = oci_parse($conn, "select does_not_exist from dual");
$r = oci_execute($stid);  
$error = error($r, $stid);
echo $error["message"];
echo $error["sql"];
echo $error["code"];
echo $error["Position"];