PHP uses get to get the solution to garbled Chinese characters in the URL: use the function [string urlencode (string $str)] to encode the string and use it in the request part of the URL. The code is [echo '< ;a href="mycgi?foo=', url].
##Solution to the garbled Chinese characters in the url obtained by PHP using get:
1. Use: The code is as follows:<a href="list.php?plate=<?php echo urlencode("辖区动态");?>" charset="utf-8" target="main">[查看]</a>
<?php header("Content-type: text/html; charset=utf-8"); if($_GET['plate']) echo $plate=urldecode($_GET['plate']); ?>
string urlencode ( string $str ) Function
urlencode()
<?php echo '<a href="mycgi?foo=', urlencode($userinput), '">'; ?>
urlencode() and
htmlentities()
<?php $query_string = 'foo=' . urlencode($foo) . '&bar=' . urlencode($bar); echo '<a href="mycgi?' . htmlentities($query_string) . '">'; ?>
Related learning recommendations:php programming (video)
The above is the detailed content of What should I do if the Chinese characters in the URL obtained by PHP are garbled?. For more information, please follow other related articles on the PHP Chinese website!