我收到错误default_method未定义
这是我的网址访问
用于从db生成id(如果没有_remap,则此工作,但具有_remap时无效)
我的公共功能更新()(如果没有_remap&&有,这不起作用 _remap)
这是我的控制器
public function _remap($method)
{
if ($method === 'update')
{
$this->$method();
}
else
{
$this->default_method();
}
}
public function index($id = NULL)
{
$exits_id = $this->Description_model->get_all_id();
if(count($exits_id) > 0)
{
foreach($exits_id as $exits_id):
$id_arr[]=$exits_id->desc_id;
endforeach;
}
if(!in_array($id, $id_arr))
{
show_404();
}
$viewdata['content']=$this->General_model->get_page_uri();
$viewdata['ha']='Indroduction / '. $id.' / ';
$this->load->view("backend/content_view",$viewdata);
}
public function update()
{
echo 'update';
}
这是我的路线
$method_arr=array(
'Dashboard',
'Googlemap',
'Deccription',
'Slideshow'
);
foreach($method_arr as $method_arr){
$route['Admin/'.strtolower($method_arr)] = 'backend/'.$method_arr;
$route['Admin/'.$method_arr] = 'backend/'.$method_arr;
$route['Admin/'.strtolower($method_arr).'/(:any)'] = 'backend/'.$method_arr.'/$1';
$route['Admin/'.$method_arr.'/(:any)'] = 'backend/'.$method_arr.'/$1';
/*This 1 line above read my function method */
}
$route['Admin/Description/(:any)'] = 'backend/Description/index/$1';
/*This 1 line above read my index($id = NULL) */
错误:调用未定义的方法说明:: default_method()
答案 0 :(得分:0)
问题解决删除函数_remap()
并将index($ id = NULL)的路由更改为其他$ route
的顶部$route['Admin/Description/(:num)'] = 'backend/Description/index/$1';
/*This 1 line above read my index($id = NULL) */
foreach($method_arr as $method_arr){
$route['Admin/'.strtolower($method_arr)] = 'backend/'.$method_arr;
$route['Admin/'.$method_arr] = 'backend/'.$method_arr;
$route['Admin/'.strtolower($method_arr).'/(:any)'] = 'backend/'.$method_arr.'/$1';
$route['Admin/'.$method_arr.'/(:any)'] = 'backend/'.$method_arr.'/$1';
/*This 1 line above read my function method */
}
但我有疑问$ route如何覆盖其他$ route