Solution to the garbled Chinese characters of JavaScript in PHP: 1. Display the declaration as GB2312 in the PHP file, and transcode the Chinese sent to the server; 2. The codes are all encoded in [UTF-8]. Can.
Solution to Chinese garbled javascript in PHP:
One of the solutions is to use PHP The file shows that the declaration is GB2312
header("Content-Type:text/html;charset=GB2312");
and the Chinese sent to the server is transcoded.
As follows
$_POST["content"]=iconv("UTF-8","gb2312",$_POST["content"]);
So this can solve the problem of garbled characters
Related learning recommendations:javascript video tutorial
The second solution is to use UTF-8 encoding.
Attached test routine
Client
Server
Related learning recommendations:php programming(video)
The above is the detailed content of What to do if JavaScript is garbled in Chinese in PHP. For more information, please follow other related articles on the PHP Chinese website!