3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(function_exists("json_encode")) { $table = get_html_translation_table(HTML_ENTITIES); $table = utf($table); echo json_encode(get_html_translation_table(HTML_ENTITIES)); } function is_utf($string) { return preg_match('%(?:[\xC2-\xDF][\x80-\xBF]|\xE0[\xA0-\xBF][\x80-\xBF]|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}|\xED[\x80-\x9F][\x80-\xBF]|\xF0[\x90-\xBF][\x80-\xBF]{2}|[\xF1-\xF3][\x80-\xBF]{3}|\xF4[\x80-\x8F][\x80-\xBF]{2})+%xs', $string); } function utf($yolo) { if(is_array($yolo)) { $result = array(); foreach($yolo as $yo => $lo) $result[utf($yo)] = utf($lo); } elseif(is_string($yolo) && !is_utf($yolo)) $result = utf_encode($yolo); else $result = $yolo; return $result; }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Call to undefined function utf_encode() in /in/HoZDV:24 Stack trace: #0 /in/HoZDV(21): utf('"') #1 /in/HoZDV(5): utf(Array) #2 {main} thrown in /in/HoZDV on line 24
Process exited with code 255.
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Fatal error: Call to undefined function utf_encode() in /in/HoZDV on line 24
Process exited with code 255.
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6

preferences:
258.48 ms | 402 KiB | 355 Q