url参数里的空格为何有时会是%20有时会是加号
If enc_type is PHP_QUERY_RFC1738, then encoding is performed per » RFC 1738 and the application/x-www-form-urlencoded media type, which implies that spaces are encoded as plus (+) signs. If enc_type is PHP_QUERY_RFC3986, then encoding is performed according to » RFC 3986, and spaces will be percent encoded (%20). 来源: https://www.php.net/manual/en/function.http-build-query.php 根据上述说明,加号或%20,两种数据标准均是RFC定义的参数格式。表单默认是application/x-www-form-urlencoded编码类型时,空格会替换成+号;普通urlencode()方法或浏览器打开的url有空格的,会替换成%20,参数编码的结果里有时会有空格,这点在传参时为何要先urlencode(),才能保证不被上述两种标准搞乱,有些框架会对经过的参数自动做urldecode(),就导致后面流程参数变形,这点也要注意