thinkphp空控制器和空方法

空控制器和空方法:

防止用户恶意输入,当非法输入时自动跳转到指定页面。


namespace app\index\controller;

use think\Controller;
class Error extends controller 
{
    public function index()
    {
        //重定向返回首页
    	$this->redirect('index/index');    	
    }

//空操作主要解决用户恶意输入一些错误的地址,如果没有这个地址就自动空操作返回到首页
    // http://127.0.0.1/composer_tp5/public/index.php/index/sdasds/dasda  这里错误的控制器和错误的方法
    public function _empty(){
        //重定向返回首页
        $this->redirect('index/index'); 
    }
}

猜你喜欢

转载自blog.csdn.net/blank__box/article/details/79773983