Advertisement
killerbng

Make sure PHP / Mysql always returns utf-8

May 25th, 2015
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. <?php
  2. header('Content-Type: charset=utf-8'); //At start of page (or at least before any output)
  3.  
  4. /*Assuming mysql/mysqli connect is set to $connect*/
  5. //MySql
  6. mysql_set_charset('UTF8',$connect);
  7. //MySqli
  8. mysqli_set_charset($connect,'utf8');
  9. ?>
  10.  
  11. //Not needed, but always helpful (placed between <head></head> tags)
  12. <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement