如何解决致命错误:未被捕获的错误:调用未定义的方法MainController :: function
我正在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 举报,一经查实,本站将立刻删除。