3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (version_compare(PHP_VERSION, '5.2', '<')) { exit 'no json_encode() support'; } $array = array('text' => "<h1>Кириллический URL</h1>\n<p>This is Cyrillic URL example. Try <a class=js-as dir=rtl href=עברית>RTL עברית</a>.</p>\n"); if (version_compare(PHP_VERSION, '5.4', '>=')) { $data = json_encode($array, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); } else { //$data = str_replace('\\/', '/', json_encode($array)); $data = preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", json_encode($array)); } echo $data;
Output for 5.4.0 - 5.4.16
Parse error: syntax error, unexpected ''no json_encode() support'' (T_CONSTANT_ENCAPSED_STRING) in /in/55tHQ on line 4
Process exited with code 255.
Output for 5.3.0 - 5.3.26
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /in/55tHQ on line 4
Process exited with code 255.

preferences:
174.16 ms | 1386 KiB | 51 Q