3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = 'ä€'; var_dump(strlen($str)); var_dump(mb_detect_encoding($str, 'auto', true)); $iso = mb_convert_encoding($str, 'iso-8859-1', 'utf-8'); var_dump(strlen($str)); var_dump($str); var_dump(mb_detect_encoding($iso, 'utf-8, iso-8859-1', true)); $utf8 = mb_convert_encoding($iso, 'utf-8', 'iso-8859-1'); $utf8 = mb_convert_encoding($utf8, 'utf-8', iso-8859-1);
based on tMn7r
Output for 7.2.0
int(5) string(5) "UTF-8" int(5) string(5) "ä€" string(10) "ISO-8859-1" Warning: Use of undefined constant iso - assumed 'iso' (this will throw an Error in a future version of PHP) in /in/cack9 on line 16 Warning: A non-numeric value encountered in /in/cack9 on line 16 Warning: mb_convert_encoding(): Illegal character encoding specified in /in/cack9 on line 16
Output for 7.1.0 - 7.1.10
int(5) string(5) "UTF-8" int(5) string(5) "ä€" string(10) "ISO-8859-1" Notice: Use of undefined constant iso - assumed 'iso' in /in/cack9 on line 16 Warning: A non-numeric value encountered in /in/cack9 on line 16 Warning: mb_convert_encoding(): Illegal character encoding specified in /in/cack9 on line 16
Output for 5.3.18 - 7.0.20
int(5) string(5) "UTF-8" int(5) string(5) "ä€" string(10) "ISO-8859-1" Notice: Use of undefined constant iso - assumed 'iso' in /in/cack9 on line 16 Warning: mb_convert_encoding(): Illegal character encoding specified in /in/cack9 on line 16