Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在CodeIgniter中,我应该在哪里放置错误对象?_Php_Codeigniter_Coding Style - Fatal编程技术网

Php 在CodeIgniter中,我应该在哪里放置错误对象?

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中放置此文件的标准文件夹是什么?在控制器中加

在我当前的PHP网站中,我正在传递描述错误的字符串。我想离开这个黑客系统,改用错误代码,所以我创建了这个错误对象:

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();