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

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

复制代码 代码如下:


<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'])

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

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 new version

SublimeText3 Linux latest version

MinGW - Minimalist GNU for Windows

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.