By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,684 Members | 1,831 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,684 IT Pros & Developers. It's quick & easy.

_Get problems with character # in url

100+
P: 123
When I use below to get the varible from a url like
test.php?aaaa=abc#1$bbbb=try
Expand|Select|Wrap|Line Numbers
  1.  
  2. $aaaa=$_GET["aaaa"];
  3. $bbbb=$_GET["bbbb"];
  4.  
  5. echo "1 : " . $aaaa . "<br />";
  6. echo "2 : " . $bbbb . "<br />";
  7.  
result will be as below
1 : abc
2:

all variable after # will be ignore, how to fix it?
Mar 12 '10 #1

✓ answered by Atli

Hey.

The # char has a special meaning in an URL. If you want to use it, you need to urlencode the string. Try replacing the # char with "%23". That is the URL special character that represents the # char.

Also, if you plan on using "bbbb" in there as a variable, you need to seperate it from the "aaaa" value using a question mark "&", not a dollar sign "$".

Share this Question
Share on Google+
1 Reply


Atli
Expert 5K+
P: 5,058
Hey.

The # char has a special meaning in an URL. If you want to use it, you need to urlencode the string. Try replacing the # char with "%23". That is the URL special character that represents the # char.

Also, if you plan on using "bbbb" in there as a variable, you need to seperate it from the "aaaa" value using a question mark "&", not a dollar sign "$".
Mar 12 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.