我有一个名为 privacy 的库,我将一个名为 _user_block_by_team 的函数设为私有(private)
我想像下面的代码一样在同一个库的另一个公共(public)函数上调用这个函数,但它给我一个错误 Fatal error: Call to undefined method Team::_user_block_by_team()
我在哪里做错了吗?该库从文件 autoload.php 自动加载
class Privacy {
function __construct()
{
$this->ci =& get_instance();
}
function user_block_team($id_user) {
$this->ci->_user_block_by_team($id_user);
}
function _user_block_by_team($id_user) {
$this->ci->load->library('settings');
if ($this->ci->settings->check_user_blocked($id_user)) {
return false;
}
return true;
}
}
最佳答案
你可以调用$this->_user_block_by_team($id_user)
。
关于php - 如何在库 codeigniter 上调用私有(private)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19428741/