且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

php用参数中的空格编码完整的URL

更新时间:2023-02-23 11:48:05

您可以使用 parse_url()将URL分成各自的部分.在parse_url返回的数组中的query元素上使用urlencode(),然后使用

You can use parse_url() to split the URL into its respective pieces. Use urlencode() on the query element from the array that parse_url returns, then put it back together using http_build_url.

注意:http_build_url需要PECL pecl_http> = 0.21.0

NOTE: http_build_url requires PECL pecl_http >= 0.21.0