我正在将 URL 变量构建到另一个名为“$url”的变量中:
$url = "page2.php?";
$url .= "&Keyword=$keyword";
$shopByStore = $_GET["store"];
if (!empty($shopByStore)) {
$url .= "&store=$shopByStore";
}
// plus many more variables built into the URL variable based on user input.
在某些情况下,我需要删除 $url 变量字符串的部分内容。 str_replace 方法不会删除放在 href 标记中的 $url 变量中的字符串部分。 “&store”的值出现在源代码和浏览器中的实际链接中。
if ($foo == "certain_condition) {
str_replace("&store=$shopByStore", "", $url);
?>
<a href="<?php echo $url; ?>">Clear</a><br>
<?php
}
非常感谢任何建议!!!