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.
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>
2. Check the encoding method of the file
Take Dreamwaver CS4 as an example, look at the logo in the lower right corner
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/">";
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!