php的urlencode和rawurlencode对空格编码的区别
我最近在使用urlencode
对字符串进行编码时发现它将空格字符串编码为了+
,但是如果你用rawurlencode
来编码,空格字符串就会变为%20
。而且在浏览器里输入空格后,它都会将其转化为%20
。
这两者有什么区别吗?后端服务器在接受这两种编码请求时会有和不同呢?
我试着将http://zh.wikipedia.org/wiki/Internet%20Explorer%207
网址替换为http://zh.wikipedia.org/wiki/Internet+Explorer+7
,发现就无法识别了。
回复内容:
我最近在使用urlencode
对字符串进行编码时发现它将空格字符串编码为了+
,但是如果你用rawurlencode
来编码,空格字符串就会变为%20
。而且在浏览器里输入空格后,它都会将其转化为%20
。
这两者有什么区别吗?后端服务器在接受这两种编码请求时会有和不同呢?
我试着将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...

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

PHP 8.4 带来了多项新功能、安全性改进和性能改进,同时弃用和删除了大量功能。 本指南介绍了如何在 Ubuntu、Debian 或其衍生版本上安装 PHP 8.4 或升级到 PHP 8.4

CakePHP 是 PHP 的开源框架。它的目的是使应用程序的开发、部署和维护变得更加容易。 CakePHP 基于类似 MVC 的架构,功能强大且易于掌握。模型、视图和控制器 gu

Visual Studio Code,也称为 VS Code,是一个免费的源代码编辑器 - 或集成开发环境 (IDE) - 可用于所有主要操作系统。 VS Code 拥有针对多种编程语言的大量扩展,可以轻松编写
