1、$_GET里的变量全都会自动进行urldecode。
例如:url?a=123!@+1&b=123
请求

php端
var_dump($_GET['a']);die;//"123!@ 1"
php自动urldecode将+ urldecode为空格
2、$_POST里的变量只有Content-Type: application/x-www-form-urlencoded下会自动进行urldecode。
前端
<form method="post" action="test.php">
<input name="username" value="1+1"/>
<button type="submit">提交</button>
</form>
请求


本文详细解析了在PHP中,_GET与_POST变量在不同条件下如何被自动URL解码。_GET变量无论何时都会自动进行urldecode,而_POST变量仅在特定的Content-Type下自动解码。
154

被折叠的 条评论
为什么被折叠?



