Solution to garbled data sent from form to php: 1. Add ""; 2. Make sure all files are utf8 encoded; 3. Add "header("Content-Type:text/html; charset=UTF-8");" to php.
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.
What should I do if the data sent from the form is garbled in PHP?
php Page form submission to php garbled code problem
html->php The solution to the Chinese garbled code problem when the form is submitted is as follows:
1. Add < at the head in html ;meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
2. Make sure all files are utf8 encoded
3. Add header("Content-Type:text/html; charset=UTF-8");
in php to solve the problem.
Related introduction:
UTF-8 (8-bit, Universal Character Set/Unicode Transformation Format) is a variable-length character encoding for Unicode. It can be used to represent any character in the Unicode standard, and the first byte in its encoding is still compatible with ASCII, so that the original software that processes ASCII characters can continue to be used without or with only a few modifications. Therefore, it has gradually become the preferred encoding for email, web pages, and other applications that store or transmit text.
UTF-8 encoding rules: If there is only one byte, the value is 0x00-0x7F. The remaining bytes are expanded as follows according to length:
UTF-8 is implemented by 4 encoding methods, namely UTF8-1 / UTF8-2 / UTF8-3 / UTF8-4
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What should I do if the data sent from the form is garbled in PHP?. For more information, please follow other related articles on the PHP Chinese website!