Php code conversion example
- /*
- * Common coding problems
- *
- * 1. page garbled characters:
- * The garbled page is mainly because the encoding of the display font is inconsistent with the encoding displayed in the browser, which is output by the browser.
- * Encoding is performed
- *. If the characters output in your program are garbled characters, it means that the fonts output by the program are not the same encoding as the ones set above, then garbled characters will appear.
- * 2. database garbled issues
- * The database has the default character encoding. if the encoding you submit is different from the encoding in the data,
- * It will also be garbled
- * (Script School bbs.it-home.org)
- * Conclusion: garbled characters are produced because the encoding of the two types of characters is different. you must try to make them the same.
- *
- * Main points:
- * 1. Header settings
- * 2. database default encoding settings
- * 3. encoding settings of the editor (sometimes this is important ,)
- * (The best way is to set the three encodings to the same)
- *
- * Sometimes garbled characters can be converted using some encoding conversion functions. You can set the same encoding,
- * Main encoding conversion functions
- * Mb_convert_encoding (str, to, from)
- * Mb_convert_encoding ("Hello everyone", "gbk", "UTF-8") (the first encoding is the destination encoding to be converted, and the second is the encoding you write in the code editor)
- *
- * Iconv (in, out, str)
- **/
- Echo mb_convert_encoding ("Hello everyone", "gbk", "UTF-8"); // garbled characters are generated in UTF-8, because the output is encoded into gbk.
- Echo iconv ("UTF-8", "gbk", "Hello everyone ");
- ?>
|