How to pass a hash tag (#) with an address bar var

2019-09-21 00:49发布

How can I pass a variable that contains a hash tag via a website URL? I currently pass this information into the URL, but cannot echo it out on the new page because '#' is used to anchor/jump to a specific page area.

Can I tell it to ignore the hash tag and echo what follows it?

Current url:

http://localhost/social3/search/?searchTerm=#JustKeepGoing

Current way to echo content:

$searchTerm = $_GET["searchTerm"];
echo $searchTerm;  

标签: php url
1条回答
走好不送
2楼-- · 2019-09-21 01:20

You have to url encode it :

http://host.com/social3/search/?searchTerm=%23JustKeepGoing

Not sure your browser won't interpret it, but worth trying.

查看更多
登录 后发表回答