3v4l.org

run code in 300+ PHP versions simultaneously
<?php $unko = "\xf0\x9f\x92\xa9"; $cesu = $this->convert_char_to_cesu8($unko); var_dump($cesu); $encode = json_encode($unko); public function convert_char_to_cesu8($utf8_char) { if (strlen($utf8_char) < 3) { return $utf8_char; } $s = mb_convert_encoding($utf8_char, 'UTF-16BE', 'UTF-8'); // UTF-16BEは 110110ww wwxxxxxx 110111xx xxxxxxxx // これを 11101101 1010wwww 10xxxxxx 11101101 1011xxxx 10xxxxxx にする $w1 = ord($s[0]) & 0b00000011; $w2 = ord($s[1]) & 0b11000000; $x1 = ord($s[1]) & 0b00111111; $x2 = ord($s[2]) & 0b00000011; $x3 = ord($s[3]); return chr(0b11101101) . chr(0b10100000 | $w1 << 2 | $w2 >> 6) . chr(0b10000000 | $x1) . chr(0b11101101) . chr(0b10110000 | $x2 << 2 | $x3 >> 6) . chr(0b10000000 | ($x3 & 0b00111111)); }

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)
5.6.140.0130.06318.14
5.6.130.0130.03018.16
5.6.120.0030.08721.10
5.6.110.0070.08321.01
5.6.100.0100.05320.98
5.6.90.0030.07021.01
5.6.80.0100.07320.50
5.6.70.4070.03320.27
5.5.300.0130.07317.97
5.5.290.0100.07717.97
5.5.280.0100.04020.80
5.5.270.0100.08320.67
5.5.260.0230.07320.76
5.5.250.0130.06320.61
5.5.240.0000.06020.25
5.4.450.0200.05719.41
5.4.440.0300.04319.29
5.4.430.0270.04319.55
5.4.420.0370.04719.54
5.4.410.0230.04718.98
5.4.400.0200.04719.29
5.4.390.0100.06018.88
5.4.380.0270.04319.24
5.4.370.0130.05719.21
5.4.360.0130.05719.04
5.4.350.0230.04719.02
5.4.340.0130.06019.01
5.4.320.0130.06319.26
5.4.310.0270.05318.96
5.4.300.0230.07318.88
5.4.290.0300.04718.88
5.4.280.0130.05719.27
5.4.270.0070.06019.23
5.4.260.0270.05319.18
5.4.250.0170.05719.22
5.4.240.0170.05019.34
5.4.230.0170.07319.23
5.4.220.0100.08019.14
5.4.210.0600.07719.07
5.4.200.0530.05019.04
5.4.190.0530.05019.04
5.4.180.0600.06319.05
5.4.170.0730.05319.26
5.4.160.0400.06319.23
5.4.150.0430.06319.21
5.4.140.0600.05316.40
5.4.130.0530.05316.54
5.4.120.0570.05716.41
5.4.110.0500.05316.60
5.4.100.0570.05716.61
5.4.90.0570.05716.45
5.4.80.0530.05716.63
5.4.70.0230.03716.43
5.4.60.0300.06316.49
5.4.50.0030.05016.58
5.4.40.0070.07316.56
5.4.30.0030.06716.38
5.4.20.0230.04016.48

preferences:
143.23 ms | 1394 KiB | 7 Q