? PHP ?,??????? URL ?????,????? urlencode()
? urldecode()
??????????????????? URL ?????? URL ??????????????
???????????????:
- ??
urlencode()
? URL ????:
$url = "https://example.com/search?q=????"; $encoded_url = urlencode($url); echo $encoded_url; // ??:https://example.com/search?q=你好世界
- ??
urldecode()
? URL ??????:
$decoded_url = urldecode($encoded_url); echo $decoded_url; // ??:https://example.com/search?q=????
???????????,?? urlencode()
???????,????????? urldecode()
?????????????????????????????
??,????? AJAX ????????,??????:
// ?? jQuery ?? AJAX ?? $.ajax({ url: 'your_server_script.php', type: 'POST', data: { 'search_query': '????' }, success: function(response) { console.log(response); } });
? your_server_script.php
???,????? urldecode()
????:
$search_query = urldecode($_POST['search_query']); echo "Search query: " . $search_query; // ??:Search query: ????
??,????????? URL ???????