_Get problems with character # in url

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • perhapscwk
    New Member
    • Sep 2007
    • 123

    _Get problems with character # in url

    When I use below to get the varible from a url like
    test.php?aaaa=a bc#1$bbbb=try
    Code:
    $aaaa=$_GET["aaaa"];
    $bbbb=$_GET["bbbb"];
    
    echo "1 : " . $aaaa . "<br />";
    echo "2 : " . $bbbb . "<br />";
    result will be as below
    1 : abc
    2:

    all variable after # will be ignore, how to fix it?
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    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 "$".

    Comment

    Working...