rawurlencode php,php的urlencode和rawurlencode对空格编码的区别

我最近在使用urlencode对字符串进行编码时发现它将空格字符串编码为了+,但是如果你用rawurlencode来编码,空格字符串就会变为%20。而且在浏览器里输入空格后,它都会将其转化为%20。

bVGQd

这两者有什么区别吗?后端服务器在接受这两种编码请求时会有和不同呢?

我试着将http://zh.wikipedia.org/wiki/Internet%20Explorer%207网址替换为http://zh.wikipedia.org/wiki/Internet+Explorer+7,发现就无法识别了。

回复内容:

我最近在使用urlencode对字符串进行编码时发现它将空格字符串编码为了+,但是如果你用rawurlencode来编码,空格字符串就会变为%20。而且在浏览器里输入空格后,它都会将其转化为%20。

bVGQd

这两者有什么区别吗?后端服务器在接受这两种编码请求时会有和不同呢?

我试着将http://zh.wikipedia.org/wiki/Internet%20Explorer%207网址替换为http://zh.wikipedia.org/wiki/Internet+Explorer+7,发现就无法识别了。

From Wikipedia (emphasis and link added):When data that has been entered into HTML forms is submitted, the form field names and values are encoded and sent to the server in an HTTP request message using method GET or POST, or, historically, via email. The encoding used by default is based on a very early version of the general URI percent-encoding rules, with a number of modifications such as newline normalization and replacing spaces with "+" instead of "%20". The MIME type of data encoded this way is application/x-www-form-urlencoded, and it is currently defined (still in a very outdated manner) in the HTML and XForms specifications.

来源:

http://stackoverflow.com/questions/16...

其他参考:

http://stackoverflow.com/questions/12...

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值