Blogger Information
Blog 14
fans 0
comment 0
visits 16095
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
URL 与重定向
依然很m丶的博客
Original
1095 people have browsed it

index 控制器

<?php
namespace app\index\controller;
class Index extends \think\Controller
{
    public function index()
    {
        return'学习中...';
    }
    public function hello($name)
    {
        if ($name=='thinkphp')
        {
            $this->success('验证成功,正在跳转...',url('demo/Login/ok'));
        }
        else{
            $this->error('验证失败,正在返回登陆页面...','http://www.php.cn');
        }
    }
}

demo/Login/

<?php
namespace app\demo\controller;
class Login extends \think\Controller
{
    public function ok()
    {
        return '欢迎使用后台登陆系统...';
    }
    public function login()
    {
        return '登陆页面...';
    }
}

--------------------------------------------------------------------------------------------------------------------------------

重定向

<?php
namespace app\index\controller;
class Index extends \think\Controller
{
    public function index()
    {
        return'学习中...';
    }
    public function hello($name)
    {
        if ($name=='thinkphp')
        {
            //redirect(路由地址,请求变量,后缀,是否显示域名)
            $this->redirect('ok',['siteName'=>'php中文网']);
        }
        else{
            $this->redirect('http://www.php.cn',302);
        }
    }
    public function ok()
    {
        return '欲穷千里目,更上一层楼';
    }
}


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post