英文原文
Realistically, you should be using debug_backtrace for this.
Eg:
function error(){
$trace = debug_backtrace();
$file = $trace[1]['file']; // use 1 because you don't want
// to include this function!
// 2 will be the function which called the function
// which called this function.
$line = $trace[1]['line'];
trigger_error("DB error in *{$file}* on line {$line}
\n " .
// You really should consider using MySQLi instead of MySQL
mysql_error() . "" . @mysql_error($this->dbl), E_USER_ERROR);
// why do you have two mysql_error calls???
}
中文翻译
例如:
function error(){
$ trace = debug_backtrace();
$ file = $ trace [1] ['file']; //使用1,因为你不想要
//包含这个功能!
// 2将是调用函数的函数
//调用了这个函数。
$ line = $ trace [1] ['line'];
trigger_error(" *< b> {$ file}< / b> *中的数据库错误*行< b> {$ line}< / b>< br /> \ n" 。
//你真的应该考虑使用MySQLi而不是MySQL
mysql_error()。 " " 。 @mysql_error($ this-> dbl),E_USER_ERROR);
//为什么你有两个mysql_error调用???
}
Realistically, you should be using debug_backtrace for this.
Eg:
function error(){
$trace = debug_backtrace();
$file = $trace[1]['file']; // use 1 because you don't want
// to include this function!
// 2 will be the function which called the function
// which called this function.
$line = $trace[1]['line'];
trigger_error("DB error in *{$file}* on line {$line}
\n " .
// You really should consider using MySQLi instead of MySQL
mysql_error() . "" . @mysql_error($this->dbl), E_USER_ERROR);
// why do you have two mysql_error calls???
}
例如:
function error(){
$ trace = debug_backtrace();
$ file = $ trace [1] ['file']; //使用1,因为你不想要
//包含这个功能!
// 2将是调用函数的函数
//调用了这个函数。
$ line = $ trace [1] ['line'];
trigger_error(" *< b> {$ file}< / b> *中的数据库错误*行< b> {$ line}< / b>< br /> \ n" 。
//你真的应该考虑使用MySQLi而不是MySQL
mysql_error()。 " " 。 @mysql_error($ this-> dbl),E_USER_ERROR);
//为什么你有两个mysql_error调用???
}