PHP:删除URL参数? [英] PHP: Remove URL Param?

查看:423
本文介绍了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

http://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: http://test.local/cart');
    ... clear the cart ...
?>

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

See the PHP reference manual for more details.

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

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