实际在项目过程中,我们经常会遇到要获取上一页地址的路径。你可以返回上一页使用
复制代码 代码如下:
<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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
