问题描述
我正在PHP中使用MVC,我有一个名为MAIN的控制器,该控制器的功能可以在接收时呈现并正常工作。 我想做的是,当从URL发送未定义函数的名称时,它向我显示了一个错误404之类的视图,因为在URL中输入值时,以下错误会跳转: 致命错误:未捕获错误:调用未定义的方法MainController :: function()
URL:良好 ... / APPWEB / main / reports
URL:错误** ... / APPWEB /主要/功能**
<?php
class MainController extends Controller{
function __construct(){
parent::__construct();
//$this->view->channels = [];
//$this->view->user = [];
//$this->view->privileges = [];
//$this->view->message="";
//echo "Nuevo Controlador";
}
function render(){
$UserID = $_SESSION['idUser'];
$user = $this->model->getUser($UserID);
$this->view->user = $user;
$channel = $this->model->getChannelByID($UserID);
$this->view->channels = $channel;
$privileges =$this->model->getPrivileges($UserID);
$this->view->privileges = $privileges;
$this->view->Title = "Home";
$this->view->render('main/index');
}
public function reports(){
$UserID = $_SESSION['idUser'];
$ChannelSession = $_SESSION['channel'];
$user = $this->model->getUser($UserID);
$this->view->user = $user;
$channel = $this->model->getChannelByID($UserID);
$this->view->channels = $channel;
$privileges =$this->model->getPrivileges($UserID);
$this->view->privileges = $privileges;
$rankings =$this->model->getRankings($ChannelSession);
$this->view->rankings = $rankings;
$this->view->Title = "Reportes";
if ($privileges->Reports == 1 || $privileges->Root == 1){
$this->view->render('main/reports');
}else{
echo "<script>
window.location.replace('".constant('URL')."main')
</script>";
}
}
[More functions]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)