PHP:删除URL参数?

编程入门 行业动态 更新时间:2024-10-25 06:27:56
本文介绍了PHP:删除URL参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个函数,该函数以?clear-cart附加到页面末尾;您可能会猜到,此功能会清除用户的购物车.

I have a function that I call with ?clear-cart appended to the end of my page; as you can probably guess, this function clears the user's cart.

我这样称呼它

<a href="?clear-cart">Clear Cart</a>

除了在地址栏中的URL现在显示为

Which works great (in that it loads the same page, but now the cart is cleared), except that the URL in the address bar now reads

test.local/cart?clear-cart

是否仍然可以调用?clear-cart,但是URL是否返回 参数? (因为我只在内部函数调用中使用它,所以对用户隐藏它?)

Is there anyway to call ?clear-cart but have the URL return without the parameter? (Hide it from the user, since I'm only using it for an internal function call??)

推荐答案

您可以清除购物车,然后立即使用标题重定向(显然在任何输出之前!).

You could clear the cart and then immediately redirect using header (obviously before any output!).

<?php header('Location: test.local/cart'); ... clear the cart ... ?>

有关更多详细信息,请参见 PHP参考手册.

See the PHP reference manual for more details.

更多推荐

PHP:删除URL参数?

本文发布于:2023-11-01 11:32:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549226.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   PHP   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!