Problem description:
The encoding method of the PHP page is utf-8. When the following code is output, a garbled window pops up.
echo "<script type='text/javascript'>alert('已全部清除!');script>";
Solution:
Because alert() outputs Chinese to the browser, you must specify the encoding method as UTF-8 in the web page, that is,
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Note: If the PHP page encoding method is gb2312, there is no need to add
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
For more related tutorials, please visit php Chinese website.
The above is the detailed content of What should I do if a garbled window pops up when executing the alert() function in the PHP page?. For more information, please follow other related articles on the PHP Chinese website!