3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function utf8ToLocalEncoding($s) { if (substr(PHP_OS, 0, 3) === 'WIN' || true) { list(, $code) = explode(".", setlocale(LC_CTYPE, 0)); $s = @iconv("UTF-8", "cp" . $code . "//TRANSLIT", $s); } return $s; } function localEncodingToUtf8($s) { if (substr(PHP_OS, 0, 3) === 'WIN' || true) { list(, $code) = explode(".", setlocale(LC_CTYPE, 0)); $s = @iconv("cp" . $code . "//TRANSLIT", "UTF-8", $s); } return $s; } $original = "šířéč"; $a = utf8toLocalEncoding($original); $b = localEncodingToUtf8($a); var_dump($original, $a, $b, $original === $b); var_dump(setlocale(LC_CTYPE, 0));
Output for 5.3.0 - 5.5.34, 5.6.7 - 5.6.20, 5.6.28, 7.0.0 - 7.0.5, 7.0.12 - 7.1.0
Notice: Undefined offset: 1 in /in/4rv3S on line 5 Notice: Undefined offset: 1 in /in/4rv3S on line 13 string(10) "šířéč" bool(false) bool(false) bool(false) string(1) "C"
Output for 7.0.6
Notice: Undefined offset: 1 in /in/4rv3S on line 5 Fatal error: Uncaught Error: Call to undefined function iconv() in /in/4rv3S:6 Stack trace: #0 /in/4rv3S(20): utf8ToLocalEncoding('\xC5\xA1\xC3\xAD\xC5\x99\xC3\xA9\xC4\x8D') #1 {main} thrown in /in/4rv3S on line 6
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: 1 in /in/4rv3S on line 5 Notice: Undefined index: 1 in /in/4rv3S on line 13 string(10) "šířéč" bool(false) bool(false) bool(false) string(0) ""
Output for 5.5.35, 5.6.21
Notice: Undefined offset: 1 in /in/4rv3S on line 5
Process exited with code 255.
Output for 5.0.0 - 5.2.17
Notice: Undefined offset: 1 in /in/4rv3S on line 5 Notice: Undefined offset: 1 in /in/4rv3S on line 13 string(10) "šířéč" bool(false) bool(false) bool(false) string(1) "C"
Output for 4.3.2 - 4.4.9
Notice: Undefined offset: 1 in /in/4rv3S on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Undefined offset: 1 in /in/4rv3S on line 5