是否可以使用PHP更改/更新URL中的查询字符串?


Is it possible to change/update a query string in a URL using PHP?

是否可以在PHP中以编程方式更改查询URL ?我知道我可以使用$_GET['something']函数从URL查询获得数据,但我不知道如何在PHP中以编程方式更改查询字符串。

这是我想要做的一个例子:

//---- index.php ----''    
$variable = 23;

我的URL是:http://example.com/index.php?variable=23

因此,如果我稍后在程序中制作$variable = 10(不使用标头,也不硬编码到链接中),我希望能够以编程方式更新查询URL,以便我的URL现在将读取:

http://example.com/index.php?variable=10

如果不使用表单,这可能吗?

header("Location: index.php?variable=10");

还是说

$_GET['variable'] = 10; 

?