我感兴趣的是如何创建自己的函数,允许它在没有错误记录的情况下执行,但前提是使用 @
运算符执行,例如 @function();
?
功能:
public function query($sql, $id = false){
$this->query_id = mysqli_query($this->connection, $sql);
if(!$this->query_id){
// I want to suppress this error call here...
psyo::error("Error while executing query (sql: {$sql}).");
return NULL;
}else{
$this->result = mysqli_store_result($this->connection);
$this->affected = mysqli_affected_rows($this->connection);
return $id ? $this->query_id : $this;
}
}
附言我正在使用我自己的错误处理类,它不是通过 error_log();
左右操作的。
提前致谢!
最佳答案
我认为没有办法知道确定是否使用了@-operator 来调用函数,但是您可以使用error_reporting()
来测试对于当前级别,当使用 @-operator 时为 0。
function test()
{
var_dump(error_reporting());
}
test();
@test();
关于php - 允许使用@进行错误抑制的功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5554862/