用PHP剥离URL参数 [英] Strip off URL parameter with PHP

查看:119
本文介绍了用PHP剥离URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PowerPoint演示文稿中有一些链接,由于某种原因,当单击这些链接时,它会向URL添加一个返回参数.好吧,该返回参数使我的Joomla网站的MVC模式变得一团糟.

I have some links in a powerpoint presentation, and for some reason, when those links get clicked, it adds a return parameter to the URL. Well, that return parameter is causing my Joomla site's MVC pattern to get bungled.

那么,使用PHP剥离此返回参数的有效方法是什么?

So, what's an efficient way to strip off this return parameter using PHP...?

示例: http://mydomain.com/index.php?id=115& ; Itemid = 283& return = aHR0cDovL2NvbW11bml0

推荐答案

最安全的正确"方法是:

The safest "correct" method would be:

  1. 使用 parse_url()
  2. 将网址解析为一个数组
  3. 提取查询部分,使用 parse_str()
  4. 通过unset()从数组中删除所需的查询参数
  5. 使用 http_build_query()
  6. 重建原始网址
  1. Parse the url into an array with parse_url()
  2. Extract the query portion, decompose that into an array using parse_str()
  3. Delete the query parameters you want by unset() them from the array
  4. Rebuild the original url using http_build_query()

快速而肮脏的是使用字符串搜索/替换和/或正则表达式杀死值.

Quick and dirty is to use a string search/replace and/or regex to kill off the value.

这篇关于用PHP剥离URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆