Method to solve php echo js garbled problem: first open the source file; then add content to the file [echo "";] That's it.
Recommendation: "php Video Tutorial"
#The problem with Chinese garbled characters in alert js in php Solution
Many friends may encounter this problem. In the php file, you may often use
echo "<script charset='utf-8' type='text/javascript'>alert('请输入正确的手机号码');window.location.href='路径';</script>";
. The result of "Please enter the correct mobile phone number" is displayed Garbled characters.
Here is a solution.
Add
echo "<meta http-equiv='Content-Type'' content='text/html; charset=utf-8'>";
above this statement. Note that the charset encoding inside needs to be filled in with the encoding corresponding to your web page. Examples are as follows:
echo "<meta http-equiv='Content-Type'' content='text/html; charset=utf-8'>"; echo "";
The above is the detailed content of How to solve the garbled problem of php echo js. For more information, please follow other related articles on the PHP Chinese website!