php的urlencode和rawurlencode对空格编码的区别
阿神
阿神 2017-04-10 13:12:17
0
1
817

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

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

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

阿神
阿神

闭关修行中......

全部回覆(1)
阿神

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...

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!