Scenario Description/Problem Description:
The Ajax commit page is encoded as gb2312, the database is encoded as UTF8, and the data is inserted without changing the page and database encoding.
Custom functions:
The code is as follows |
| < td="">
| Return eval (' Return '. Iconv ($in _charset, $out _charset,var_export ($arr, true). '; '); }
Function Description:
Var_export sets the second argument to True, returns the array prototype string, converts the string to Utf-8 encoding, and then uses Eval to perform the return.
Example:
The code is as follows |
| < td="">
| $data = Array_iconv (' gb2312 ', ' utf-8 ', $postdata) Print_r ($data);
With the help of the Firefox Firebug component we can see:
Then look at the database:
You can see that the encoding is OK and the storage is successful
Articles you may be interested in
- PHP array Encoding Conversion example Demo
- Solve the problem of generating XML files Chinese character coding php array arrays
- Cyclic implementations in PHP (strings, objects, or arrays) encode each other
http://www.bkjia.com/PHPjc/741658.html www.bkjia.com true http://www.bkjia.com/PHPjc/741658.html techarticle Scenario Description/Problem Description: The AJAX submission page is encoded as gb2312, the database is encoded as UTF8, and the data is inserted without changing the page and database encoding. Custom functions: The code is as follows ...