我有一个函数,该函数以?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参数?
发布评论