Php 在CodeIgniter中,我应该在哪里放置错误对象?
在我当前的PHP网站中,我正在传递描述错误的字符串。我想离开这个黑客系统,改用错误代码,所以我创建了这个错误对象:Php 在CodeIgniter中,我应该在哪里放置错误对象?,php,codeigniter,coding-style,Php,Codeigniter,Coding Style,在我当前的PHP网站中,我正在传递描述错误的字符串。我想离开这个黑客系统,改用错误代码,所以我创建了这个错误对象: class Error { const DATABASE = 0; // database failure const CACHE = 1; // cache miss const NETWORK = 2; // network is down // ... etc ... } 在CodeIgniter中放置此文件的标准文件夹是什么?在控制器中加
class Error
{
const DATABASE = 0; // database failure
const CACHE = 1; // cache miss
const NETWORK = 2; // network is down
// ... etc ...
}
在CodeIgniter中放置此文件的标准文件夹是什么?在控制器中加载此类文件的标准方式是什么?我可能会将其放入
/application/libraries/
(请参阅CodeIgniter约定)
然后按如下方式加载库:
$this->load->library('yourErrorClass');
$this->yourErrorClass->someLoggingFunction();
..并使用以下功能之一:
$this->load->library('yourErrorClass');
$this->yourErrorClass->someLoggingFunction();