load->controller()中的一个类?
这里高手如云,向各位请教一个问题:怎么从controller中的一个类里面,读取另外一个controller的类?或者是说怎么加载controller中例外一个类?
先感谢所有人. 不能从一个控制器调用另外一个控制器 你看看这里的各位老大们翻译的那本书。
那里很好的解释了。为什么不可以这样的。和解决方案 是的,控制器不可以调用另外的控制器。 谢谢各位的答案.
我用了 include_once, 导入想要的controller/testing, 然后new Testing();
但是出现错误:
all to a member function _assign_libraries() on a non-object in D:\projects\gene24\web\doc-root\system\libraries\Loader.php on line 1038.
其中的函数是:
function _ci_assign_to_models()
{
if (count($this->_ci_models) == 0)
{
return;
}
if ($this->_ci_is_instance())
{
$CI =& get_instance();
foreach ($this->_ci_models as $model)
{
$CI->$model->_assign_libraries();
}
}
else
{
foreach ($this->_ci_models as $model)
{
$this->$model->_assign_libraries();
}
}
}
1308行是:$CI->$model->_assign_libraries();
请问这个问题怎么解决? 请问那本书叫什么名字? 谢谢! 3# yuwen002 《PHP 敏捷开发框架 CodeIgniter》
应该是指这本,在公告和置顶的帖子里有 谢谢你! 7# bnlt2009 我已经说过了,控制器不能直接调用另外的控制器。
有这种需求的,应该从设计角度重新思考自己的项目。 谢谢你们的好意见,但是这个问题必须得用调用controller的函数.
我的方法是:
include_once('models_users.php');
$class= new ReflectionClass('models_users');
// echo $class;
$methods = array();
foreach ($class->getMethods() as $method)
{
$methods[] = $method->getName();
}
var_dump($methods);
就取得了例外一个函数的方法.
页:
[1]
2