0
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.
, I는 $ URL 변수 문자열의 일부를 제거해야합니다 . str_replace 메소드는 href 태그에있는 $ url 변수의 문자열 부분을 제거하지 않습니다. 소스 코드와 브라우저의 실제 링크에 '& store'값이 표시됩니다.
if ($foo == "certain_condition) {
str_replace("&store=$shopByStore", "", $url);
?>
<a href="<?php echo $url; ?>">Clear</a><br>
<?php
}
왜 ** ** "특정 조건"이외에서 변수 대신 다시 제거 후 추가하는 추가하지 마십시오? –
pseudo'if' 문에 오타가 있습니다 (닫는'''이 없습니다). – faintsignal