3v4l.org

run code in 300+ PHP versions simultaneously
<?php function unicode_encode($str, $encoding = 'GBK', $prefix = '&#', $postfix = ';') { $str = iconv($encoding, 'UCS-2', $str); $arrstr = str_split($str, 2); $unistr = ''; for($i = 0, $len = count($arrstr); $i < $len; $i++) { $dec = hexdec(bin2hex($arrstr[$i])); $unistr .= $prefix . $dec . $postfix; } return $unistr; } /** * $str Unicode编码后的字符串 * $decoding 原始字符串的编码,默认GBK * $prefix 编码字符串的前缀,默认"&#" * $postfix 编码字符串的后缀,默认";" */ function unicode_decode($unistr, $encoding = 'GBK', $prefix = '&#', $postfix = ';') { $arruni = explode($prefix, $unistr); $unistr = ''; for($i = 1, $len = count($arruni); $i < $len; $i++) { if (strlen($postfix) > 0) { $arruni[$i] = substr($arruni[$i], 0, strlen($arruni[$i]) - strlen($postfix)); } $temp = intval($arruni[$i]); $unistr .= ($temp < 256) ? chr(0) . chr($temp) : chr($temp / 256) . chr($temp % 256); } return iconv('UCS-2', $encoding, $unistr); } //GBK字符串测试 $str = '<b>哈哈</b>'; echo $str.'<br />'; $unistr = unicode_encode($str); echo $unistr.'<br />'; // &#60;&#98;&#62;&#21704;&#21704;&#60;&#47;&#98;&#62; $str2 = unicode_decode($unistr); echo $str2.'<br />'; //<b>哈哈</b> //UTF-8字符串测试 $utf8_str = iconv('GBK', 'UTF-8', $str); echo $utf8_str.'<br />'; // <b>鍝堝搱</b> 注:UTF在GBK下显示的乱码!可切换浏览器的编码测试 $utf8_unistr = unicode_encode($utf8_str, 'UTF-8'); echo $utf8_unistr.'<br />'; // &#60;&#98;&#62;&#21704;&#21704;&#60;&#47;&#98;&#62; $utf8_str2 = unicode_decode($utf8_unistr, 'UTF-8'); echo $utf8_str2.'<br />'; // <b>鍝堝搱</b> //其它后缀、前缀测试 $prefix_unistr = unicode_encode($str, 'GBK', "\\u", ''); echo $prefix_unistr.'<br />'; // \u60\u98\u62\u21704\u21704\u60\u47\u98\u62 $profix_unistr2 = unicode_decode($prefix_unistr, 'GBK', "\\u", ''); echo $profix_unistr2.'<br />'; //<b>哈哈</b>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.70.0070.01116.88
8.3.60.0160.00318.35
8.3.50.0120.01021.14
8.3.40.0110.01118.71
8.3.30.0100.00320.27
8.3.20.0040.00420.35
8.3.10.0040.00422.09
8.3.00.0080.00022.34
8.2.180.0070.01416.75
8.2.170.0070.01122.96
8.2.160.0080.00620.43
8.2.150.0040.00424.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00420.93
8.2.110.0100.00020.79
8.2.100.0060.00617.84
8.2.90.0000.00918.16
8.2.80.0040.00418.03
8.2.70.0050.00517.63
8.2.60.0050.00317.63
8.2.50.0040.00417.55
8.2.40.0030.00519.36
8.2.30.0040.00417.59
8.2.20.0040.00417.66
8.2.10.0040.00417.70
8.2.00.0000.00817.77
8.1.280.0070.00725.92
8.1.270.0100.00023.99
8.1.260.0070.00726.35
8.1.250.0040.00428.09
8.1.240.0060.00323.88
8.1.230.0040.00822.75
8.1.220.0080.00017.74
8.1.210.0030.00518.77
8.1.200.0000.00917.35
8.1.190.0070.00317.35
8.1.180.0030.00518.10
8.1.170.0040.00418.96
8.1.160.0060.00318.82
8.1.150.0040.00418.90
8.1.140.0040.00417.47
8.1.130.0000.00817.89
8.1.120.0080.00017.50
8.1.110.0060.00317.43
8.1.100.0080.00017.47
8.1.90.0040.00417.38
8.1.80.0040.00417.48
8.1.70.0070.00017.48
8.1.60.0030.00617.59
8.1.50.0000.00817.46
8.1.40.0050.00317.52
8.1.30.0000.00817.58
8.1.20.0080.00017.58
8.1.10.0000.00817.49
8.1.00.0050.00317.57
8.0.300.0090.00019.98
8.0.290.0000.00916.75
8.0.280.0040.00418.08
8.0.270.0000.00718.09
8.0.260.0030.00316.95
8.0.250.0000.00717.00
8.0.240.0030.00517.07
8.0.230.0000.00717.02
8.0.220.0000.00716.94
8.0.210.0000.00716.99
8.0.200.0030.00317.02
8.0.190.0000.00716.97
8.0.180.0060.00317.02
8.0.170.0000.00917.01
8.0.160.0000.00816.93
8.0.150.0000.00716.99
8.0.140.0050.00216.98
8.0.130.0000.00513.42
8.0.120.0000.01117.04
8.0.110.0120.00017.18
8.0.100.0000.01017.21
8.0.90.0000.01017.10
8.0.80.0100.01017.11
8.0.70.0000.00917.16
8.0.60.0030.00917.05
8.0.50.0100.00017.02
8.0.30.0110.01717.49
8.0.20.0070.02017.40
8.0.10.0030.00617.33
8.0.00.0150.00716.79
7.4.330.0000.00516.70
7.4.320.0000.00816.45
7.4.300.0060.00016.66
7.4.290.0000.00716.61
7.4.280.0070.00016.50
7.4.270.0030.00316.48
7.4.260.0050.00013.24
7.4.250.0050.00516.90
7.4.240.0040.00516.83
7.4.230.0050.00516.87
7.4.220.0160.01016.94
7.4.210.0060.01716.83
7.4.200.0000.00916.79
7.4.190.0050.00517.05
7.4.160.0090.01216.63
7.4.150.0090.01217.40
7.4.140.0120.00917.86
7.4.130.0060.01916.89
7.4.120.0070.01616.79
7.4.110.0150.00716.71
7.4.100.0060.01416.72
7.4.90.0070.01516.72
7.4.80.0100.01019.39
7.4.70.0090.01416.66
7.4.60.0140.01816.82
7.4.50.0140.00816.82
7.4.40.0140.00819.74
7.4.30.0110.01516.74
7.4.20.0090.01816.42
7.4.10.0060.01516.75
7.4.00.0070.01216.19
7.3.330.0000.00513.20
7.3.320.0020.00213.20
7.3.310.0060.00316.55
7.3.300.0000.00916.56
7.3.290.0060.01816.54
7.3.280.0100.01016.65
7.3.270.0110.02017.40
7.3.260.0070.01516.60
7.3.250.0100.01116.72
7.3.240.0080.02016.57
7.3.230.0120.00816.56
7.3.210.0060.01516.64
7.3.200.0130.00616.63
7.3.190.0150.01716.95
7.3.180.0180.01116.71
7.3.170.0140.01716.62
7.3.160.0140.00816.75
7.3.150.0110.01116.75
7.3.140.0140.00716.59
7.3.130.0050.01816.63
7.3.120.0110.01315.91
7.3.110.0090.01416.75
7.3.100.0110.00916.77
7.3.90.0150.01116.61
7.3.80.0090.01116.54
7.3.70.0160.00516.69
7.3.60.0080.01416.58
7.3.50.0080.01116.77
7.3.40.0100.01016.47
7.3.30.0070.01416.57
7.3.20.0090.01218.32
7.3.10.0130.00718.45
7.3.00.0110.02118.32
7.2.330.0120.01217.03
7.2.320.0040.01817.07
7.2.310.0180.01516.95
7.2.300.0160.01917.08
7.2.290.0070.01616.88
7.2.280.0030.02117.05
7.2.270.0110.01416.68
7.2.260.0130.00916.78
7.2.250.0210.00816.93
7.2.240.0110.01716.82
7.2.230.0130.01317.04
7.2.220.0180.00316.96
7.2.210.0120.01616.69
7.2.200.0070.01316.99
7.2.190.0030.02016.88
7.2.180.0070.01416.92
7.2.170.0050.01616.84
7.2.160.0120.00916.86
7.2.150.0100.01418.52
7.2.140.0100.01018.71
7.2.130.0130.01018.67
7.2.120.0070.01417.78
7.2.110.0090.01517.78
7.2.100.0090.00917.70
7.2.90.0100.00917.93
7.2.80.0080.01317.83
7.2.70.0100.00917.86
7.2.60.0100.00817.62
7.2.50.0030.01317.84
7.2.40.0060.01217.83
7.2.30.0080.00818.08
7.2.20.0060.01517.88
7.2.10.0050.01417.94
7.2.00.0070.01118.47
7.1.330.0210.01117.67
7.1.320.0230.01317.67
7.1.310.0190.01317.97
7.1.300.0250.00717.66
7.1.290.0200.01217.57
7.1.280.0240.01017.71
7.1.270.0150.01517.75
7.1.260.0210.01117.75
7.1.250.0230.01417.78
7.1.240.0120.01316.82
7.1.230.0110.01216.89
7.1.220.0140.00916.97
7.1.210.0130.01216.87
7.1.200.0090.01216.64
7.1.190.0150.00816.78
7.1.180.0120.01316.82
7.1.170.0130.01016.86
7.1.160.0130.00917.00
7.1.150.0090.01416.85
7.1.140.0140.01216.88
7.1.130.0170.00816.80
7.1.120.0130.01116.84
7.1.110.0140.00916.81
7.1.100.0130.00617.44
7.1.90.0090.01416.98
7.1.80.0120.01516.88
7.1.70.0120.00917.00
7.1.60.0120.00917.13
7.1.50.0130.00817.00
7.1.40.0090.00916.95
7.1.30.0100.01016.86
7.1.20.0110.01016.95
7.1.10.0090.01116.86
7.1.00.0080.01016.83
7.0.330.0200.01217.45
7.0.320.0100.01216.38
7.0.310.0120.01116.44
7.0.300.0090.01516.48
7.0.290.0140.00516.57
7.0.280.0130.01016.45
7.0.270.0140.01116.63
7.0.260.0070.01516.63
7.0.250.0120.01016.46
7.0.240.0090.01116.60
7.0.230.0140.01016.59
7.0.220.0140.01216.38
7.0.210.0100.01316.48
7.0.200.0100.00716.71
7.0.190.0110.00816.67
7.0.180.0090.01316.66
7.0.170.0110.00616.61
7.0.160.0090.01016.48
7.0.150.0120.00716.54
7.0.140.0090.01216.55
7.0.130.0090.00916.65
7.0.120.0060.01616.66
7.0.110.0080.00916.61
7.0.100.0060.01516.57
7.0.90.0090.01116.63
7.0.80.0090.01016.57
7.0.70.0090.00916.59
7.0.60.0110.00916.49
7.0.50.0100.01016.75
7.0.40.0120.00715.68
7.0.30.0110.00815.67
7.0.20.0100.00915.62
7.0.10.0060.01615.68
7.0.00.0130.00515.61
5.6.400.0210.01216.46
5.6.390.0120.02016.12
5.6.380.0120.01215.82
5.6.370.0170.01015.57
5.6.360.0070.01615.38
5.6.350.0150.00815.63
5.6.340.0090.01615.44
5.6.330.0170.00815.43
5.6.320.0140.01015.42
5.6.310.0120.01415.67
5.6.300.0130.02117.32
5.6.290.0110.02217.39
5.6.280.0070.02617.33
5.6.270.0100.02217.35
5.6.260.0080.02317.45
5.6.250.0120.03417.51
5.6.240.0100.02617.38
5.6.230.0140.02317.52
5.6.220.0130.02317.44
5.6.210.0100.02117.50
5.6.200.0100.02517.49
5.6.190.0130.02017.26
5.6.180.0070.03017.36
5.6.170.0150.02017.24
5.6.160.0160.01617.30
5.6.150.0150.02417.48
5.6.140.0090.02317.37
5.6.130.0070.02717.44
5.6.120.0090.02417.54
5.6.110.0160.01917.33
5.6.100.0110.02217.25
5.6.90.0080.02517.32
5.6.80.0150.02017.00
5.6.70.0080.02717.12
5.6.60.0090.02317.08
5.6.50.0090.02617.02
5.6.40.0100.02017.09
5.6.30.0110.02417.20
5.6.20.0090.02117.13
5.6.10.0060.02717.22
5.6.00.0110.02217.10
5.5.380.0110.01815.06
5.5.370.0150.01814.99
5.5.360.0090.02215.09
5.5.350.0100.01715.04
5.5.340.0140.01915.30
5.5.330.0090.02115.26
5.5.320.0120.02115.17
5.5.310.0070.02415.32
5.5.300.0090.02215.22
5.5.290.0090.02615.23
5.5.280.0100.02115.36
5.5.270.0110.02115.21
5.5.260.0090.02415.30
5.5.250.0090.02115.18
5.5.240.0110.02415.11
5.5.230.0070.02114.98
5.5.220.0070.02315.06
5.5.210.0120.01815.07
5.5.200.0140.01714.97
5.5.190.0060.02715.02
5.5.180.0090.02115.13
5.5.170.0140.01015.24
5.5.160.0060.02315.12
5.5.150.0090.02215.11
5.5.140.0090.02215.12
5.5.130.0080.02315.08
5.5.120.0070.02015.03
5.5.110.0080.02415.15
5.5.100.0110.01915.08
5.5.90.0100.02414.96
5.5.80.0080.02214.97
5.5.70.0110.02415.03
5.5.60.0090.02115.02
5.5.50.0090.02515.04
5.5.40.0090.01915.08
5.5.30.0110.02314.84
5.5.20.0090.02914.99
5.5.10.0140.01414.98
5.5.00.0110.02214.93
5.4.450.0050.02014.54
5.4.440.0070.02114.53
5.4.430.0040.02114.43
5.4.420.0070.02014.48
5.4.410.0090.01714.53
5.4.400.0080.02114.43
5.4.390.0060.01914.37
5.4.380.0040.02114.38
5.4.370.0060.02214.47
5.4.360.0120.01214.40
5.4.350.0100.01814.32
5.4.340.0060.02114.40
5.4.330.0090.00911.95
5.4.320.0050.02314.43
5.4.310.0070.02814.40
5.4.300.0090.01714.40
5.4.290.0100.01714.48
5.4.280.0060.02114.35
5.4.270.0070.02014.43
5.4.260.0110.01714.41
5.4.250.0080.01614.33
5.4.240.0090.01914.38
5.4.230.0090.01714.43
5.4.220.0110.02014.44
5.4.210.0090.01714.37
5.4.200.0090.02314.45
5.4.190.0080.02614.45
5.4.180.0110.01714.38
5.4.170.0100.01614.44
5.4.160.0100.01814.49
5.4.150.0090.01814.37
5.4.140.0060.01813.58
5.4.130.0120.02513.57
5.4.120.0080.02113.65
5.4.110.0060.02913.54
5.4.100.0120.01513.64
5.4.90.0070.02313.62
5.4.80.0090.02913.57
5.4.70.0090.03013.67
5.4.60.0130.01813.64
5.4.50.0090.01713.65
5.4.40.0150.01613.63
5.4.30.0070.01713.57
5.4.20.0090.01513.67
5.4.10.0120.01413.63
5.4.00.0070.02713.36
5.3.290.0050.02413.59
5.3.280.0090.01913.54
5.3.270.0060.02513.57
5.3.260.0080.02513.56
5.3.250.0080.02113.56
5.3.240.0090.02113.52
5.3.230.0060.02513.59
5.3.220.0090.02113.52
5.3.210.0070.02513.53
5.3.200.0110.01813.56
5.3.190.0050.02713.60
5.3.180.0100.03213.65
5.3.170.0080.02013.60
5.3.160.0110.02213.56
5.3.150.0090.02013.56
5.3.140.0080.02013.60
5.3.130.0060.02213.65
5.3.120.0090.02313.56
5.3.110.0070.03213.61
5.3.100.0090.02013.56
5.3.90.0060.02113.60
5.3.80.0040.02513.53
5.3.70.0060.02413.51
5.3.60.0070.01713.54
5.3.50.0050.02013.57
5.3.40.0050.02313.58
5.3.30.0070.03313.60
5.3.20.0070.02113.58
5.3.10.0020.02113.50
5.3.00.0050.02513.46
5.2.170.0070.01913.24
5.2.160.0080.01413.25
5.2.150.0060.02613.28
5.2.140.0050.02513.25
5.2.130.0080.01413.23
5.2.120.0050.01913.26
5.2.110.0070.01613.22
5.2.100.0080.01413.21
5.2.90.0080.02713.19
5.2.80.0090.01813.16
5.2.70.0080.02113.21
5.2.60.0080.01813.16
5.2.50.0070.02013.19
5.2.40.0110.01313.18
5.2.30.0090.01213.22
5.2.20.0110.01213.21
5.2.10.0070.01513.13
5.2.00.0050.01613.14
5.1.60.0100.01213.07
5.1.50.0050.01513.07
5.1.40.0060.01413.07
5.1.30.0030.02213.07
5.1.20.0050.01713.07
5.1.10.0080.01413.07
5.1.00.0050.01413.07
5.0.50.0070.01213.07
5.0.40.0050.01213.07
5.0.30.0070.01413.07
5.0.20.0060.01013.07
5.0.10.0030.01613.07
5.0.00.0030.02513.07
4.4.90.0050.00613.07
4.4.80.0060.00713.07
4.4.70.0030.00713.07
4.4.60.0010.01013.07
4.4.50.0010.01013.07
4.4.40.0040.01113.07
4.4.30.0020.00913.07
4.4.20.0030.00713.07
4.4.10.0030.01013.07
4.4.00.0050.00913.07
4.3.110.0030.00913.07
4.3.100.0040.00713.07
4.3.90.0040.00713.07
4.3.80.0030.02213.07
4.3.70.0050.00913.07
4.3.60.0010.01013.07
4.3.50.0050.01213.07
4.3.40.0040.01213.07
4.3.30.0040.01513.07
4.3.20.0050.01113.07
4.3.10.0050.00613.07
4.3.00.0020.00813.07

preferences:
47.32 ms | 401 KiB | 5 Q