fork download
  1. <?php
  2.  
  3. $str = "apple";
  4. var_dump(mb_detect_encoding($str, "ASCII, UTF-8"));
  5.  
  6. $str_with_bom = chr(0xEF) . chr(0xBB) . chr(0xBF) . "apple";
  7. var_dump(mb_detect_encoding($str_with_bom, "ASCII, UTF-8"));
Success #stdin #stdout 0.02s 52472KB
stdin
Standard input is empty
stdout
string(5) "ASCII"
string(5) "UTF-8"