? PHP ?,urlencode()
? urldecode()
????? URL ??????????????????? URL ??????,??????????????????
1. ?? urlencode()
? URL ????
?????????????????? URL ?,???? urlencode()
???????????:
$search_term = "PHP & MySQL"; $encoded_search_term = urlencode($search_term); echo $encoded_search_term; // ??:PHP+&+MySQL
???????? +
??,?? &
????? &
?
2. ?? urldecode()
? URL ????
???? URL ???????????,???? urldecode()
???????????:
$encoded_string = "PHP+&+MySQL"; $decoded_string = urldecode($encoded_string); echo $decoded_string; // ??:PHP & MySQL
??? +
???????,?? &
??? &
???
3. ??? URL ??? http_build_query()
??????????????? URL ?,???? http_build_query()
?????????????????,?????? urlencode()
???:
$params = [ 'search' => 'PHP & MySQL', 'page' => 2, ]; $query_string = http_build_query($params); echo $query_string; // ??:search=PHP+&+MySQL&page=2
???????????????,???????? URL ??
4. ?? $_GET
???? URL ??
????????????? URL ?,PHP ??????????????? $_GET
?????????,??????? urldecode()
???:
// ?? URL ?:example.com/search.php?search=PHP+&+MySQL echo $_GET['search']; // ??:PHP & MySQL
??????????? "PHP & MySQL"?
??,? PHP ??? URL ??????,???? urlencode()
?urldecode()
?http_build_query()
? $_GET
????????????????????? URL ???????