各类跳转


headers()  适用于不留中转界面,前面不能有输出 例:headers("location:http://www.baidu");

也可用于延迟的例子  如:headers("Refresh:延迟的秒数;url=要跳转的地址");

js中

location.href="将要跳转的地址;

confirm('你是否要跳转到 ***?'){

     location.href="将要跳转的地址; 

}

tp5框架中

<?php
namespace app\index\controller;

use app\index\model\User;
use think\Controller;

class Index extends Controller
{
    public function index()
    {
        $User   = new User; //实例化User对象
        $result = $User->save($data);
        if ($result) {
            //设置成功后跳转页面的地址,默认的返回页面是$_SERVER['HTTP_REFERER']
            $this->success('新增成功', 'User/list');
        } else {
            //错误页面的默认跳转页面是返回前一页,通常不需要设置
            $this->error('新增失败');
        }
    }
}

猜你喜欢

转载自blog.csdn.net/liuyubing2018/article/details/80952943