A new project is not a problem in the local (WIN8) test, but the data that is queried from the Sqlite3 database when it is uploaded to the server (Linux) is garbled (normal in the database), and the PHP files and HTML files are set to unified UTF8 or the same. There is no use in finding solutions on the Web. WORKAROUND: Re-process the queried data and cast all to UTF8
Open db.db Table $db = new SQLite3 (' db.db '), if (! $db) { echo $db->lasterrormsg (); Exit;} else {} $keys = array (), $students = Array (),//Query $ret = $db->query ("SELECT * FROM Student limit 50"),//Save the result to the new array while ($ro W = $ret->fetcharray (SQLITE3_ASSOC)) { $keys = Array_keys ($row); Convert column values to prevent garbled foreach ($keys as $key) { $row [$key] = mb_convert_encoding ($row [$key], "gb2312", "Utf-8"); } Add to new array Array_push ($students, $row);} $db->close ();p rint_r ($students);
Reference: Sqlite#pragma_encoding A summary of the SQLite version and Chinese garbled set pragma encoding = "UTF-16" for main database in SQLite
From for notes (Wiz)
The problem and solution about Sqlite3 Chinese garbled in Linux system