3v4l.org

run code in 300+ PHP versions simultaneously
<?php function entities( $string ) { $stringBuilder = ""; $offset = 0; if ( empty( $string ) ) { return ""; } while ( $offset >= 0 ) { $decValue = ordutf8( $string, $offset ); $char = unichr($decValue); $htmlEntited = htmlentities( $char ); if( $char != $htmlEntited ){ $stringBuilder .= $htmlEntited . " "; } elseif( $decValue >= 128 ){ $stringBuilder .= "&#" . $decValue . "; "; } else { $stringBuilder .= $char . " "; } } return $stringBuilder; } // source - http://php.net/manual/en/function.ord.php#109812 function ordutf8($string, &$offset) { $code = ord(substr($string, $offset,1)); if ($code >= 128) { //otherwise 0xxxxxxx if ($code < 224) $bytesnumber = 2; //110xxxxx else if ($code < 240) $bytesnumber = 3; //1110xxxx else if ($code < 248) $bytesnumber = 4; //11110xxx $codetemp = $code - 192 - ($bytesnumber > 2 ? 32 : 0) - ($bytesnumber > 3 ? 16 : 0); for ($i = 2; $i <= $bytesnumber; $i++) { $offset ++; $code2 = ord(substr($string, $offset, 1)) - 128; //10xxxxxx $codetemp = $codetemp*64 + $code2; } $code = $codetemp; } $offset += 1; if ($offset >= strlen($string)) $offset = -1; return $code; } // source - http://php.net/manual/en/function.chr.php#88611 function unichr($u) { return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES'); } /* ---- */ var_dump( entities( "😂🧜‍♂️" ) );

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.4.120.0100.00517.83
8.4.110.0120.00824.28
8.4.100.0130.00717.91
8.4.90.0130.00720.70
8.4.80.0130.00718.81
8.4.70.0060.00220.67
8.4.60.0120.00820.37
8.4.50.0100.00918.69
8.4.40.0100.01017.60
8.4.30.0070.00419.79
8.4.20.0000.01118.87
8.4.10.0090.00017.93
8.3.250.0090.01016.55
8.3.240.0130.00616.85
8.3.230.0040.00516.79
8.3.220.0110.00819.02
8.3.210.0130.00718.62
8.3.200.0050.00416.32
8.3.190.0060.00218.92
8.3.180.0110.00818.59
8.3.170.0130.00616.92
8.3.160.0180.00018.47
8.3.150.0000.00816.83
8.3.140.0130.00318.81
8.3.130.0080.00018.48
8.3.120.0050.00518.86
8.3.110.0050.00520.94
8.3.100.0040.00424.06
8.3.90.0040.01126.77
8.3.80.0090.00017.97
8.3.70.0090.00616.62
8.3.60.0190.00018.31
8.3.50.0130.00318.36
8.3.40.0150.00618.97
8.3.30.0070.00718.46
8.3.20.0050.00318.65
8.3.10.0040.00421.90
8.3.00.0040.00421.85
8.2.290.0070.01216.65
8.2.280.0100.00918.29
8.2.270.0090.00917.48
8.2.260.0000.00816.57
8.2.250.0040.00416.61
8.2.240.0060.00317.39
8.2.230.0110.00022.58
8.2.220.0160.00037.54
8.2.210.0110.00726.77
8.2.200.0070.00316.38
8.2.190.0150.00017.95
8.2.180.0080.01118.41
8.2.170.0160.00422.96
8.2.160.0090.00619.07
8.2.150.0030.00624.18
8.2.140.0040.00424.66
8.2.130.0050.00322.04
8.2.120.0000.00826.35
8.2.110.0090.00021.06
8.2.100.0120.00318.16
8.2.90.0000.00818.34
8.2.80.0000.00917.97
8.2.70.0000.00818.16
8.2.60.0000.00918.34
8.2.50.0040.00418.10
8.2.40.0030.00619.31
8.2.30.0040.00420.68
8.2.20.0000.01018.14
8.2.10.0050.00318.20
8.2.00.0050.00319.54
8.1.330.0120.00716.53
8.1.320.0100.01017.83
8.1.310.0110.00718.33
8.1.300.0060.00317.72
8.1.290.0030.00630.84
8.1.280.0120.00325.92
8.1.270.0090.00020.24
8.1.260.0070.00026.35
8.1.250.0070.00028.09
8.1.240.0140.00722.13
8.1.230.0030.00920.91
8.1.220.0040.00417.79
8.1.210.0050.00318.77
8.1.200.0040.00417.23
8.1.190.0040.00416.99
8.1.180.0030.00518.10
8.1.170.0000.00818.62
8.1.160.0050.00318.89
8.1.150.0000.00718.96
8.1.140.0030.00519.04
8.1.130.0030.00320.29
8.1.120.0040.00417.58
8.1.110.0050.00317.48
8.1.100.0060.00317.45
8.1.90.0000.00817.55
8.1.80.0050.00317.52
8.1.70.0030.00617.55
8.1.60.0040.00717.61
8.1.50.0030.00617.51
8.1.40.0040.00417.64
8.1.30.0080.00017.67
8.1.20.0030.00617.68
8.1.10.0080.00017.55
8.1.00.0030.00517.55
8.0.300.0040.00419.53
8.0.290.0050.00316.75
8.0.280.0000.00718.42
8.0.270.0000.00717.35
8.0.260.0000.00618.54
8.0.250.0030.00317.05
8.0.240.0090.00017.04
8.0.230.0040.00416.94
8.0.220.0040.00416.94
8.0.210.0000.00716.90
8.0.200.0030.00316.91
8.0.190.0000.00717.00
8.0.180.0050.00317.02
8.0.170.0030.00617.00
8.0.160.0000.00716.92
8.0.150.0000.00716.98
8.0.140.0030.00617.01
8.0.130.0060.00013.44
8.0.120.0000.00816.96
8.0.110.0040.00417.00
8.0.100.0000.00716.81
8.0.90.0050.00316.84
8.0.80.0080.01116.95
8.0.70.0000.00716.77
8.0.60.0050.00317.01
8.0.50.0000.00716.89
8.0.30.0120.00516.89
8.0.20.0120.00617.40
8.0.10.0000.00717.02
8.0.00.0060.01116.87
7.4.330.0030.00315.55
7.4.320.0060.00016.52
7.4.300.0030.00516.70
7.4.290.0000.00716.54
7.4.280.0040.00416.58
7.4.270.0070.00016.60
7.4.260.0090.00016.58
7.4.250.0000.00816.58
7.4.240.0000.00716.49
7.4.230.0030.00316.63
7.4.220.0080.00016.80
7.4.210.0110.00516.68
7.4.200.0070.00016.69
7.4.160.0090.00716.59
7.4.140.0110.00817.86
7.4.130.0000.01716.48
7.4.120.0090.00916.53
7.4.110.0110.00716.63
7.4.100.0130.00616.50
7.4.90.0170.00616.51
7.4.80.0080.00819.39
7.4.70.0090.01216.71
7.4.60.0130.00316.53
7.4.50.0110.00216.45
7.4.40.0060.00916.69
7.4.00.0030.01414.75
7.3.330.0040.00413.45
7.3.320.0000.00513.52
7.3.310.0080.00016.44
7.3.300.0000.00716.44
7.3.290.0000.00816.45
7.3.280.0070.00916.46
7.3.260.0090.00816.59
7.3.240.0110.00816.66
7.3.230.0140.00316.52
7.3.210.0090.01016.71
7.3.200.0000.01916.46
7.3.190.0120.00916.61
7.3.180.0100.01316.59
7.3.170.0060.01616.56
7.3.160.0090.00916.38
7.2.330.0070.01016.83
7.2.320.0090.00816.89
7.2.310.0100.00716.68
7.2.300.0070.01016.54
7.2.290.0100.01316.67
7.2.100.0250.00814.65
7.2.90.2840.01314.62
7.2.80.2550.01214.75
7.2.70.3630.00514.81
7.2.60.3270.00814.85
7.2.50.1970.00314.71
7.2.40.4420.01514.61
7.2.30.4310.01114.87
7.2.20.4950.00815.06
7.2.10.3980.01014.92
7.2.00.3520.00514.91
7.1.220.1280.01114.08
7.1.210.1310.01013.61
7.1.200.2770.00213.73
7.1.190.0530.00513.89
7.1.180.1500.01213.69
7.1.170.2920.01013.81
7.1.160.0390.00813.79
7.1.150.0180.01013.77
7.1.140.4210.00513.99
7.1.130.3840.00613.61
7.1.120.3820.01013.92
7.1.110.3830.00613.82
7.1.100.3560.00513.65
7.1.90.4420.00513.95
7.1.80.4290.00513.83
7.1.70.3460.00813.68
7.1.60.4930.01031.57
7.1.50.5990.01431.45
7.1.40.5900.00731.79
7.1.30.5820.00831.54
7.1.20.5710.00831.71
7.1.10.5760.00713.61
7.1.00.3920.00814.01

preferences:
30.13 ms | 403 KiB | 5 Q