title: Emoji Support in PHP & MySQL
body: <p>I've been asked to enable Emoji support for an APP backed by a PHP API. The APP is currently iPhone only (i don't have one, but i'm assuming it has Emoji's on it?).</p>
  
  <p>Anyway, i noticed the database for some reason uses latin_swedish everywhere. But since i wasn't sure if utf-8 could support the 4 byte character strings required for the full emoji range, i started googling, but couldn't realy get a full answer from the results.</p>
  
  <p>So:</p>
  
  <ol>
  <li><p>To support Emoji's, do the charset's/collation's need setting to utf-8 in mysql, or utf-8 mb4?</p></li>
  <li><p>If charset needs setting to utf8mb4, what is the difference between utf8 and utf8mb4 (utf8 supports up to 4 bytes anyway doesnt it?). Does it force characters to be stored in 4 byte representations at a fixed width (assuming requiring 4x more storage space per chatacter even on the standard ascii range which would normally be 1 byte).</p></li>
  <li><p>Can utf8 be compared to utf8mb4 in mysql queries? What if i try to do a full text search, or a where clause on a utf8mb4 charset against a utf8 column of another table?</p></li>
  <li><p>Does PHP support 4byte strings without having to use a special library like mb_string? i.e. can i just assign <code>$var = $_POST['text']</code> and do things like <code>$emoji_var == 'xxxx'</code> or do i have to literally change all strings in PHP to use mbstring and change all comparitors e.c.t.</p></li>
  </ol>
  
  <p>Just trying to work out how much work is involved in having emoji support, and any caveats of doing so. So any help would be great. </p>