Home > PHP Framework > ThinkPHP > How to implement retreat in thinkphp5.1

How to implement retreat in thinkphp5.1

藏色散人
Release: 2022-12-05 09:53:05
Original
1303 people have browsed it

thinkphp5.1 method to implement retreat: 1. Add constants in "common/function.php"; 2. Call ""; 3. Just add javascript code to the page for the jump operation.

How to implement retreat in thinkphp5.1

The operating environment of this tutorial: Windows 7 system, thinkphp version 5.1, Dell G3 computer.

How to implement retreat in thinkphp5.1?

Thinkphp implementation plan for returning to the previous page

In the development process, the function of returning to the previous page is often used. Here I provide an idea For reference only, welcome to discuss

The implementation process is as follows:

1) Add constants in common/function.php

//当前页面的完整URL地址,用于操作返回上一页
defined('CURRENT_URL') or define('CURRENT_URL',base64_encode($_SERVER["REQUEST_URI"]));
Copy after login

2) Use the method at the link that needs to be returned Call

<a href="{:U(&#39;User/logistics?return=&#39;.CURRENT_URL)}" target="blank">添加收货地址</a>
Copy after login

3) Add javascript code in the page of the jump operation

<script>
var return_url = "{$Think.get.return|base64_decode}";
if(return_url){
          //延时跳转
         setTimeout(function () { 
               window.location.href = reurl;
         },1500);
}
</script>
Copy after login

The jump link uses base64 encoding to avoid pathinfo mode url parameter conflict

Recommended learning: "thinkPHP Video Tutorial"

The above is the detailed content of How to implement retreat in thinkphp5.1. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template