错误处理的最佳方式是什么?这是我想出的:
class test {
public static function Payment($orderid, $total) {
if (empty($orderid) && empty($total)) {
return array('status' => 'fail', 'error' => 'Missing Data');
}
}
}
我听说过 Try/Exceptions,但如何将它应用到我的代码中?如果您能提供示例,那就太好了!
最佳答案
如果你使用 PHP 5,你可以用异常处理错误:
http://fr2.php.net/manual/en/class.exception.php
这种方式比手动设置异常消息更干净,因为您可以访问 try catch 系统并且可以隔离异常处理
关于php - 更好的错误处理方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5967153/