Question mark in the middle of a url variable?

前端 未结 3 445
梦如初夏
梦如初夏 2020-11-30 07:23

If I have a variable to pass through a url and it has a question mark in it, do I just need to escape the question mark? If not how can I make sure it passes through like it

相关标签:
3条回答
  • 2020-11-30 07:39

    A question mark URL encodes as %3F. But you should use a proper encoder for the whole thing rather than manually encoding a character.

    0 讨论(0)
  • 2020-11-30 07:40

    According to my experience of trying to make a JavaScript search engine that links to Google, just replace the question marks with %3F. A url reads the first two characters on the right of a % as hexadecimal format.

    0 讨论(0)
  • 2020-11-30 07:54

    Here's a full list of URL encoding characters. If you're using PHP for a server side language, you can use something like...

    $nice_url = urlencode("http://your.old.url");
    

    Other languages will have similar functions build in (or you can find one online). This will take care of your question mark (and other url issues).

    0 讨论(0)
提交回复
热议问题