实际在项目过程中,我们经常会遇到要获取上一页地址的路径。你可以返回上一页使用
复制代码 代码如下:
<script>window.history.go(-1);</script>
这个是通过JS来操作的
如果出现这样的场景,当用户需要退出帐号,你又希望他退出后直接在返回当前页面
比如,当前页面的地址为http://xxx/module.php?module=groupbook&view=index&id=2.
你退出系统想必会使用 $_SERVER['REQUEST_URI'] 来 获取当前路径,然后把这个值做为参数传给退出需要返回的路径,这个时候你回发现
他只获取了http://xxx/module.php?module=groupbook 却没有得到&view=index&id=2,也就是说我们退出后返回的地址变成了
http://xxx/module.php?module=groupbook(本应该是http://xxx/module.php?module=groupbook&view=index&id=2),
这是因为他把&当成第一个的参数了,简单理解为
http://xxx/login.php?op=logout&return=http://xxx/module.php?module=groupbook&view=index&id=2,
变成了
http://xxx/login.php?op=logout&return=http://xxx/module.php?module=groupbook&view=index&id=2。
这个时候我们需要对当前获取的$_SERVER['REQUEST_URI'] 进行转码使用urlencode($_SERVER['REQUEST_URI'])
就可以解决我们的问题

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Linux new version
SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.