glassfish Posted October 17, 2014 Share Posted October 17, 2014 The Script: <?php echo "<h1>The Hashtag: </h1>"; echo $_GET['hashtag']; ?> An example for the URL on localhost: /search.php?hashtag=#xbox If I am not using the number sign, then the word "xbox" does get printed on screen, if I do use the number sign then the hashtag "#xbox" does not get printed on screen. Any suggestions on how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/291883-how-to-user-the-number-sign-for-the-get-method/ Share on other sites More sharing options...
Solution davidannis Posted October 17, 2014 Solution Share Posted October 17, 2014 (edited) You need to encode the # ?hashtag=%23xbox You can find an explanation here or Google it. Edited October 17, 2014 by davidannis Quote Link to comment https://forums.phpfreaks.com/topic/291883-how-to-user-the-number-sign-for-the-get-method/#findComment-1493995 Share on other sites More sharing options...
glassfish Posted October 17, 2014 Author Share Posted October 17, 2014 Thanks for the answer. This is how I have gotten it to work: <?php $string = "#xbox"; echo "<a href='search.php?hashtag=" . urlencode($string) . "'>#xbox</a>"; echo "<h1>The Hashtag: </h1>"; if(isset($_GET['hashtag'])){ echo $_GET['hashtag']; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/291883-how-to-user-the-number-sign-for-the-get-method/#findComment-1493998 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.