我正在尝试创建一个库(在应用程序/库中),但是当我从控制器调用它时遇到了问题。
以下是控制器中的代码
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Client extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->library('security');
}
function index() {
try {
$activation_code = 'aa';
$this->security->Check_User_By_ValidationCode($activation_code);
} catch (Exception $e) {
log('error', $e->getMessage());
}
}
}
?>
这就是我在库中的内容
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Security {
var $CI;
public function __construct()
{
$this->CI =& get_instance();
}
public function Check_User_By_ValidationCode($activation_code) {
return $activation_code ;
}
}
?>
但我收到“HTTP错误500(内部服务器错误):服务器尝试完成请求时遇到意外情况。”在Chrome中。 我无法从日志中得到任何东西所以我不知道我在这里做错了什么。 有线索吗?
由于
答案 0 :(得分:2)
您不能使用类security
,因为该类是由CodeIgniter定义的。只需将名称更改为其他内容,例如&#34; Auth&#34;或者更具描述性的东西。
请参阅:http://ellislab.com/codeigniter/user_guide/libraries/security.html