]."/> ].">

Home  >  Article  >  Backend Development  >  What should I do if a garbled window pops up when executing the alert() function in the PHP page?

What should I do if a garbled window pops up when executing the alert() function in the PHP page?

王林
王林Original
2020-04-25 16:27:592612browse

What should I do if a garbled window pops up when executing the alert() function in the PHP page?

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=&#39;text/javascript&#39;>alert(&#39;已全部清除!&#39;);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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does php mvc mean?Next article:What does php mvc mean?