URL as URL's get parameters - problem with “&”

前端 未结 3 1616
猫巷女王i
猫巷女王i 2021-01-24 16:10

There is script that receives another url as GET parameter:

script.php?file=http://www.google.com&id=123

The problem is:
when url has p

3条回答
  •  盖世英雄少女心
    2021-01-24 16:47

    Try to encode every special character like this:

    script.php?file=http%3a%2f%2fwww.google.com%3fq%3dadsf%26lang%3den&id=123
    

    although it might be better and easier to use rawurlencode().

    Also, read this about URL encoding.

提交回复
热议问题