Solar Posted October 22, 2012 Share Posted October 22, 2012 I understand the $_GET[''] function.. but I have ran into an error. Lets say my URL is localhost.php/test.php?say=#hello The $_GET[''] function will only take the print after the equal and before the pound sign. - Which is blank My question is... What function should I use to parse after the # sign? Thanks, Steven Quote Link to comment https://forums.phpfreaks.com/topic/269760-_get/ Share on other sites More sharing options...
xfactorr Posted October 22, 2012 Share Posted October 22, 2012 (edited) you can use substr($_GET["say"], 1); to remove # sign Edited October 22, 2012 by xfactorr Quote Link to comment https://forums.phpfreaks.com/topic/269760-_get/#findComment-1386889 Share on other sites More sharing options...
requinix Posted October 22, 2012 Share Posted October 22, 2012 The anchor/fragment (the thing after the #) is never sent to the server. You will never receive it ever. $_GET["say"] will be empty. Quote Link to comment https://forums.phpfreaks.com/topic/269760-_get/#findComment-1386892 Share on other sites More sharing options...
cyberRobot Posted October 22, 2012 Share Posted October 22, 2012 If the value needs to contain a # symbol, you could encode it: <?php print '<a href="localhost.php/test.php?say=' . urlencode('#hello') . '">Test</a>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/269760-_get/#findComment-1386944 Share on other sites More sharing options...
ManiacDan Posted October 22, 2012 Share Posted October 22, 2012 Also, $_GET is an array, not a function. It's a regular variable except for its scope. Quote Link to comment https://forums.phpfreaks.com/topic/269760-_get/#findComment-1386952 Share on other sites More sharing options...
Solar Posted October 22, 2012 Author Share Posted October 22, 2012 I have decided to take a different approach to this method. After researching; everyone's reply is the same response I recieved when reviewing the PHP.net website. Thank-you for your time, if the method was possible, it would have saved me a ton of time. But in the long run, the method I expected is not proper. Thanks again, Solar Quote Link to comment https://forums.phpfreaks.com/topic/269760-_get/#findComment-1386971 Share on other sites More sharing options...
ManiacDan Posted October 22, 2012 Share Posted October 22, 2012 Just to be clear: This method works perfectly well for every non-reserved character. Characters like @, #, &, ?, /, and = are reserved for use as URL delimiters, which is why they need to be escaped. All you'd have to do is change #hello to $hello (or something else) and it would have started working. Unless you're relying on the specific behavior of jump-to-tag while also trying to get that tag in a PHP script, in which case you should know that jumping to tags on the same page never refreshes the page, so PHP never happens. Quote Link to comment https://forums.phpfreaks.com/topic/269760-_get/#findComment-1386973 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.