search
Homephp教程php手册php获得url参数中具有&的值的方法

经常会遇到要获取上一页地址的路径。你可以返回上一页使用,实现这个是通过JS来操作的,下面有个不错的示例,大家可以参考下

实际在项目过程中,我们经常会遇到要获取上一页地址的路径。你可以返回上一页使用

复制代码 代码如下:


<script>window.history.go(-1);</script>


这个是通过JS来操作的

如果出现这样的场景,当用户需要退出帐号,你又希望他退出后直接在返回当前页面

比如,当前页面的地址为?module=groupbook&view=index&id=2.

你退出系统想必会使用 $_SERVER['REQUEST_URI'] 来 获取当前路径,然后把这个值做为参数传给退出需要返回的路径,这个时候你回发现

他只获取了?module=groupbook 却没有得到&view=index&id=2,也就是说我们退出后返回的地址变成了

?module=groupbook(本应该是?module=groupbook&view=index&id=2),

这是因为他把&当成第一个的参数了,,简单理解为

?op=logout&return=http://xxx/module.php?module=groupbook&view=index&id=2,

变成了

?op=logout&return=http://xxx/module.php?module=groupbook&view=index&id=2。

这个时候我们需要对当前获取的$_SERVER['REQUEST_URI'] 进行转码使用urlencode($_SERVER['REQUEST_URI'])

就可以解决我们的问题
Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.