Home > Backend Development > PHP Problem > What should I do if the alert function is garbled when using JavaScript in PHP?

What should I do if the alert function is garbled when using JavaScript in PHP?

coldplay.xixi
Release: 2023-03-02 10:36:02
Original
2457 people have browsed it

The solution to the garbled alert function when using JavaScript in PHP: 1. Specify the character set in the html language and use the [] tag; 2. Check the encoding method of the file; 3. Use the echo function to output.

What should I do if the alert function is garbled when using JavaScript in PHP?

Solution to the garbled alert function when using JavaScript in PHP:

1. Specified characters in html language Set, use the tag

Example:
     <html>
         <head>
           <title>编码那点事</title>
           <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        </head> 
    </html>
Copy after login

2. Check the encoding method of the file

Take Dreamwaver CS4 as an example, look at the logo in the lower right corner

What should I do if the alert function is garbled when using JavaScript in PHP?

Just save it as the same encoding method you specified. This is often easily overlooked.

3. Similar to specifying the encoding method in programming languages ​​​​such as php, using the echo function to output (I found that the echo function has other powerful functions besides output. It can be used as a function return value in JQuery and Ajax. So far, I I still think this is a magical use)

echo "<meta http-equiv=/"Content-Type/" content=/"text/html; charset=utf-8/">";
Copy after login

Related learning recommendations: PHP programming from entry to proficiency

The above is the detailed content of What should I do if the alert function is garbled when using JavaScript in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template