PHP?urlencode()
?????????????,?????URL????,??????????????????????????urlencode()
?????????:
- ????:?URL??????,??????????,???????????????,??????????????,????
urlencode()
??????????,????????????URL?????
$keyword = "Hello World!"; $encoded_keyword = urlencode($keyword); $url = "https://example.com/search?" . $encoded_keyword;
- API????:???API???,?????????????,???????????????,?????????API?,????
urlencode()
???????????,????????????API?????
$city = "Beijing"; $encoded_city = urlencode($city); $api_url = "https://api.weather.com/v1/weather?city=" . $encoded_city;
- ??URL:???URL?,????
urldecode()
???????URL????,???????????,?????????????????URL?,????urldecode()
?????????,??????????????
$encoded_url = "https://example.com/search?keyword=你好!"; $decoded_url = urldecode($encoded_url); parse_str($decoded_url['query'], $params);
??,urlencode()
?????URL???API???????URL?????????,?????????????????????????