簡體   English   中英

在關鍵字之間添加+ PHP

[英]Adding + between keywords PHP

在我的標簽雲中,我的網址看起來像這樣

  • ../search.php?query=cat&select=all
  • ../search.php?query=the cat&select=all

我想做的是,如果關鍵字是多個單詞,例如:

  • ../search.php?query=the cat&select=all

在這樣的單詞之間加上一個+

  • ../search.php?query=the+cat&select=all

我的默認搜索功能在表單執行的搜索中使用+ ,但我也希望標簽雲具有相同的功能。 我這樣做只是為了外觀。 它按原樣工作得很好,但是我想我還是會問。 有人可以幫忙嗎? 這是我當前用於標簽雲中鏈接的內容

echo " <a href='../search.php?query=$word&amp;select=all' target='rel' title='".($word)."'>".($word)."</a>";

謝謝。

我認為您正在尋找的是urlencode()函數。

urlencodeurldecode只是您需要的功能。

echo " <a href='../search.php?query=".urlencode($word)."&amp;select=all' target='rel' title='".($word)."'>".($word)."</a>";

在另一頁上,您可以使用urldecode

echo urldecode($_GET['query']);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM