3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Warning: Undefined array key 1 in /in/4rv3S on line 5 Warning: Undefined array key 1 in /in/4rv3S on line 13 string(10) "šířéč" bool(false) bool(false) bool(false) string(1) "C"
Output for 8.0.13
Warning: Undefined array key 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 7.4.33
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 5.3.0 - 5.3.29, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.25, 7.4.27 - 7.4.32
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.3.32 - 7.3.33, 7.4.26
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 5.4.0 - 5.4.45
Notice: Undefined offset: 1 in /in/4rv3S on line 5
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.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.3.11, 4.4.0 - 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

preferences:
283.37 ms | 401 KiB | 465 Q