3v4l.org

run code in 300+ PHP versions simultaneously
<?php define("TYPE_HTML_TEXT",1); define("TYPE_NUMBER", 2); define("TYPE_BOOLEAN", 3); define("TYPE_SCRIPT", 4); define("TYPE_BINARY", 5); define("TYPE_URL", 6); define("TYPE_LIST_ITEM", 7); define("TYPE_LIST", 8); define("TYPE_COLOR", 9); define("TYPE_CSS_ATTR", 10); define("TYPE_CSS_ATTR_COLOR", 11); define("TYPE_CSS_ATTR_SIZE", 12); define("TYPE_CSS_CUSTOM", 13); define("TYPE_SIZE", 14); define("TYPE_CDATA", 15); define("TYPE_CONFIG", 16); define("TYPE_HTML_MARKUP", 17); /** * ord() alternative that works with UTF8 characters * @param string $c * * @return int UTF-8 character code value */ function getUTF8CharCode($c) { $h = ord($c{0}); if ($h <= 0x7F) { return $h; } else if ($h < 0xC2) { return false; } else if ($h <= 0xDF) { return ($h & 0x1F) << 6 | (ord($c{1}) & 0x3F); } else if ($h <= 0xEF) { return ($h & 0x0F) << 12 | (ord($c{1}) & 0x3F) << 6 | (ord($c{2}) & 0x3F); } else if ($h <= 0xF4) { return ($h & 0x0F) << 18 | (ord($c{1}) & 0x3F) << 12 | (ord($c{2}) & 0x3F) << 6 | (ord($c{3}) & 0x3F); } else { return -1; } } /** * Escape a single character for CSS context. * @param $c * @return string */ function escapeCSSCharacter($c) { return "\\" . base_convert(getUTF8CharCode($c), 10, 16) . " "; } /** * Escape CSS rule * * @param string $data The CSS rule * @param array $immuneChars Array of immune character. These characters will not be escaped. * * @return string Escaped string */ function escapeCSSValue($data, array $immuneChars = array()) { $result = ""; for ($i = 0; $i < mb_strlen($data); $i++) { $currChar = mb_substr($data, $i, 1); if (getUTF8CharCode($currChar) < 256 && //Character with ASCII value of 255 or less are dangerous! !preg_match("/^\w$/", $currChar) && //Alphanumeric and underscores are safe. !in_array($currChar, $immuneChars) //Immune characters are safe. ) { $result .= escapeCSSCharacter($currChar); } else { $result .= $currChar; } } return $result; } function encodeJSONProperty($type, $value, $raw = false) { global $ESCAPE_PROPERTIES; if ($raw || !$ESCAPE_PROPERTIES) { //$raw == true means to explicitly not escape. //$ESCAPE_PROPERTIES is the feature flag. True means we want escaping. return $value; } switch ($type) { case TYPE_HTML_TEXT: return htmlspecialchars($value); case TYPE_CONFIG: case TYPE_LIST_ITEM: case TYPE_LIST: case TYPE_HTML_MARKUP: return $value; case TYPE_NUMBER: return (int)$value; case TYPE_BOOLEAN: return stristr($value, "true") != false; case TYPE_SCRIPT: return new JSONFunction($value); case TYPE_URL: return urlencode($value); case TYPE_COLOR: case TYPE_SIZE: return escapeCSSValue($value, array("#", ",", ".", "(", ")", "-", "%", "*", "+", "=", "/")); } } echo encodeJSONProperty(TYPE_HTML_TEXT, "<script>Evil</script>");

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.60.0150.00618.55
8.3.50.0160.00722.09
8.3.40.0110.01118.45
8.3.30.0070.00718.96
8.3.20.0080.00020.21
8.3.10.0050.00323.64
8.3.00.0040.00420.77
8.2.180.0090.01216.38
8.2.170.0000.01422.96
8.2.160.0110.00420.47
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0000.00726.16
8.2.120.0040.00420.69
8.2.110.0060.00320.38
8.2.100.0040.00817.78
8.2.90.0040.00418.98
8.2.80.0050.00317.97
8.2.70.0080.00017.50
8.2.60.0060.00317.80
8.2.50.0000.00918.07
8.2.40.0030.00619.95
8.2.30.0040.00418.13
8.2.20.0050.00317.62
8.2.10.0060.00317.95
8.2.00.0030.00517.56
8.1.280.0120.00325.92
8.1.270.0040.00423.88
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.92
8.1.230.0090.00317.42
8.1.220.0090.00017.74
8.1.210.0030.00518.77
8.1.200.0060.00617.25
8.1.190.0040.00417.10
8.1.180.0060.00318.10
8.1.170.0000.00818.46
8.1.160.0000.00821.92
8.1.150.0000.00718.43
8.1.140.0060.00317.32
8.1.130.0080.00017.81
8.1.120.0000.00817.27
8.1.110.0090.00017.33
8.1.100.0030.00517.32
8.1.90.0000.00717.32
8.1.80.0040.00417.37
8.1.70.0000.00717.33
8.1.60.0090.00017.51
8.1.50.0000.00817.47
8.1.40.0040.00417.42
8.1.30.0060.00317.55
8.1.20.0060.00317.44
8.1.10.0000.00717.32
8.1.00.0100.00017.32
8.0.300.0000.00818.77
8.0.290.0050.00316.63
8.0.280.0000.00718.37
8.0.270.0000.00717.15
8.0.260.0000.00717.07
8.0.250.0040.00416.93
8.0.240.0030.00316.82
8.0.230.0000.00816.96
8.0.220.0000.00716.80
8.0.210.0000.00716.71
8.0.200.0030.00316.91
8.0.190.0040.00416.96
8.0.180.0000.00716.91
8.0.170.0000.00816.79
8.0.160.0040.00416.88
8.0.150.0050.00216.87
8.0.140.0090.00316.86
8.0.130.0060.00013.34
8.0.120.0000.00816.82
8.0.110.0000.00716.70
8.0.100.0000.00716.80
8.0.90.0050.00316.70
8.0.80.0090.00616.89
8.0.70.0000.00816.75
8.0.60.0040.00416.77
8.0.50.0080.00016.79
8.0.30.0100.01016.85
8.0.20.0170.00617.40
8.0.10.0050.00217.03
8.0.00.0100.00916.60
7.4.330.0000.00515.00
7.4.320.0000.00616.66
7.4.300.0030.00316.50
7.4.290.0000.00716.54
7.4.280.0030.00616.61
7.4.270.0000.00816.52
7.4.260.0030.00316.62
7.4.250.0070.00016.49
7.4.240.0040.00316.61
7.4.230.0040.00416.60
7.4.220.0060.01216.65
7.4.210.0100.01016.70
7.4.200.0020.00516.63
7.4.160.0170.00016.71
7.4.150.0110.00717.40
7.4.140.0080.01017.86
7.4.130.0130.00416.46
7.4.120.0070.01216.58
7.4.110.0100.01316.61
7.4.100.0140.00916.61
7.4.90.0120.00616.68
7.4.80.0030.01719.39
7.4.70.0030.01616.74
7.4.60.0080.00816.51
7.4.50.0060.00316.42
7.4.40.0160.00316.29
7.4.30.0120.01216.47
7.4.10.0140.00716.50
7.4.00.0070.01115.78
7.3.330.0030.00313.45
7.3.320.0050.00213.25
7.3.310.0030.00316.27
7.3.300.0040.00416.33
7.3.290.0060.00916.38
7.3.280.0080.01116.35
7.3.270.0140.00317.40
7.3.260.0120.00616.47
7.3.250.0120.00816.57
7.3.240.0090.01616.33
7.3.230.0140.00316.47
7.3.210.0100.00716.68
7.3.200.0170.00019.39
7.3.190.0070.01116.46
7.3.180.0030.01316.49
7.3.170.0090.01016.45
7.3.160.0040.01216.46
7.3.130.0100.00716.34
7.3.120.0100.00715.73
7.3.110.0070.01016.49
7.3.100.0030.01416.47
7.3.90.0100.00716.47
7.3.80.0040.01116.54
7.3.70.0060.00616.39
7.3.60.0090.00316.32
7.3.50.0090.00016.33
7.3.40.0030.01216.36
7.3.30.0040.01116.46
7.3.20.0030.00618.20
7.3.10.0070.00718.15
7.3.00.0000.01318.01
7.2.330.0110.00716.61
7.2.320.0180.00016.76
7.2.310.0040.01416.33
7.2.300.0100.00716.64
7.2.290.0110.01116.68
7.2.260.0070.01416.41
7.2.250.0090.01216.37
7.2.240.0030.01216.52
7.2.230.0100.00616.70
7.2.220.0000.01116.38
7.2.210.0130.00316.46
7.2.200.0000.01516.40
7.2.190.0050.00516.75
7.2.180.0030.00616.56
7.2.170.0070.01116.41
7.2.160.0090.00616.60
7.2.150.0040.00718.35
7.2.140.0060.00918.34
7.2.130.0030.01518.35
7.2.120.0060.00918.21
7.2.110.0060.00618.50
7.2.100.0100.00718.44
7.2.90.0120.00318.30
7.2.80.0030.01218.42
7.2.70.0030.01018.30
7.2.60.0050.00617.62
7.2.50.0060.00918.22
7.2.40.0070.00718.34
7.2.30.0090.00618.15
7.2.20.0060.01018.47
7.2.10.0070.00718.49
7.2.00.0050.00918.88
7.1.330.0070.00717.47
7.1.320.0000.01317.45
7.1.310.0000.01317.32
7.1.300.0080.00417.29
7.1.290.0000.01317.19
7.1.280.0070.01017.34
7.1.270.0040.00817.39
7.1.260.0060.00617.35
7.1.250.0080.00417.54
7.1.240.0070.00717.30
7.1.230.0050.00517.39
7.1.220.0070.00717.18
7.1.210.0100.00017.39
7.1.200.0070.00716.45
7.1.190.0060.00617.14
7.1.180.0100.00017.13
7.1.170.0070.01017.38
7.1.160.0030.00717.25
7.1.150.0040.01117.19
7.1.140.0060.00917.20
7.1.130.0090.00317.38
7.1.120.0100.00317.34
7.1.110.0030.01017.37
7.1.100.0060.00817.89
7.1.90.0120.00317.51
7.1.80.0060.00917.43
7.1.70.0040.00617.22
7.1.60.0020.01217.20
7.1.50.0080.01017.15
7.1.40.0030.01417.27
7.1.30.0090.00617.41
7.1.20.0100.00617.43
7.1.10.0050.00817.53
7.1.00.0030.04219.75
7.0.330.0000.01316.95
7.0.320.0120.00016.84
7.0.310.0060.00916.90
7.0.300.0090.01216.90
7.0.290.0090.00916.78
7.0.280.0030.01016.87
7.0.270.0110.00316.89
7.0.260.0000.01017.10
7.0.250.0060.00616.92
7.0.240.0110.00316.99
7.0.230.0060.01216.83
7.0.220.0030.00916.89
7.0.210.0050.00516.86
7.0.200.0000.01516.86
7.0.190.0000.01516.92
7.0.180.0030.01316.88
7.0.170.0040.01116.93
7.0.160.0140.00316.86
7.0.150.0060.00616.85
7.0.140.0050.03819.62
7.0.130.0070.00716.88
7.0.120.0030.01216.87
7.0.110.0090.00316.95
7.0.100.0120.00316.92
7.0.90.0060.00317.02
7.0.80.0090.00616.83
7.0.70.0040.01216.92
7.0.60.0160.03718.44
7.0.50.0070.03217.43
7.0.40.0050.04517.61
7.0.30.0170.03417.44
7.0.20.0160.02717.64
7.0.10.0100.04217.51
7.0.00.0080.04017.58
5.6.400.0120.00316.26
5.6.390.0070.00716.00
5.6.380.0070.00315.93
5.6.370.0030.00915.93
5.6.360.0100.01016.02
5.6.350.0030.01515.66
5.6.340.0000.01016.19
5.6.330.0030.01415.58
5.6.320.0090.00616.07
5.6.310.0030.00915.93
5.6.300.0090.00615.98
5.6.290.0000.01715.61
5.6.280.0030.04218.53
5.6.270.0100.00015.80
5.6.260.0100.00715.83
5.6.250.0000.01416.16
5.6.240.0080.00415.78
5.6.230.0060.00915.83
5.6.220.0040.00815.95
5.6.210.0080.02518.11
5.6.200.0070.03717.05
5.6.190.0080.04718.36
5.6.180.0190.04118.11
5.6.170.0180.04018.18
5.6.160.0080.04718.22
5.6.150.0100.04016.95
5.6.140.0030.04717.04
5.6.130.0020.03117.15
5.6.120.0060.03118.48
5.6.110.0050.04118.46
5.6.100.0130.04218.57
5.6.90.0040.02618.57
5.6.80.0060.01918.08
5.6.70.2230.01918.09
5.6.60.0100.00616.02
5.6.50.0080.00816.14
5.6.40.0070.01115.53
5.6.30.0080.00815.82
5.6.20.0040.01115.70
5.6.10.0090.00615.45
5.6.00.0060.00315.67
5.5.380.0040.00715.75
5.5.370.0070.00715.67
5.5.360.0090.00615.80
5.5.350.0170.01517.96
5.5.340.0030.04116.71
5.5.330.0090.03917.81
5.5.320.0230.04017.99
5.5.310.0150.03117.93
5.5.300.0080.04016.99
5.5.290.0120.03716.64
5.5.280.0080.02518.22
5.5.270.0050.02318.20
5.5.260.0130.03518.30
5.5.250.0030.03918.05
5.5.240.0210.04017.86
5.5.230.0100.00315.37
5.5.220.0030.01215.71
5.5.210.0040.01115.74
5.5.200.0040.01115.54
5.5.190.0070.00715.40
5.5.180.0000.01315.59
5.5.170.0100.00015.44
5.5.160.0060.00915.69
5.5.150.0060.00915.48
5.5.140.0030.00615.84
5.5.130.0000.01315.68
5.5.120.0030.01315.29
5.5.110.0000.01515.28
5.5.100.0070.00315.60
5.5.90.0100.00015.46
5.5.80.0030.01215.72
5.5.70.0070.00415.57
5.5.60.0090.00615.54
5.5.50.0120.00615.57
5.5.40.0150.00315.73
5.5.30.0090.00315.61
5.5.20.0060.00615.23
5.5.10.0090.00615.66
5.5.00.0060.00915.30
5.4.450.0080.03116.69
5.4.440.0550.03616.60
5.4.430.0480.03016.81
5.4.420.0480.03616.72
5.4.410.0400.03016.71
5.4.400.0530.02816.42
5.4.390.0450.03616.68
5.4.380.0080.03716.26
5.4.370.0070.03416.30
5.4.360.0130.02816.34
5.4.350.0030.03916.38
5.4.340.0170.03016.24
5.4.330.0030.00913.98
5.4.320.0060.01913.25
5.4.310.0050.02413.25
5.4.300.0060.02513.26
5.4.290.0050.02413.25
5.4.280.0050.02813.20
5.4.270.0060.02413.20
5.4.260.0060.02413.20
5.4.250.0040.02713.20
5.4.240.0100.02013.21
5.4.230.0050.02613.20
5.4.220.0150.04713.20
5.4.210.0090.03213.20
5.4.200.0070.03213.20
5.4.190.0100.02913.20
5.4.180.0090.02513.20
5.4.170.0070.02713.20
5.4.160.0060.02613.20
5.4.150.0060.02613.20
5.4.140.0080.02713.04
5.4.130.0050.03713.03
5.4.120.0060.02613.01
5.4.110.0060.02813.01
5.4.100.0070.02613.01
5.4.90.0040.02813.01
5.4.80.0050.03013.01
5.4.70.0070.02713.01
5.4.60.0040.02813.01
5.4.50.0070.02713.01
5.4.40.0060.02813.00
5.4.30.0070.02613.00
5.4.20.0050.02913.00
5.4.10.0080.02613.00
5.4.00.0090.02612.74
5.3.290.0060.02313.39
5.3.280.0080.02813.35
5.3.270.0080.03013.36
5.3.260.0050.02913.35
5.3.250.0040.02813.35
5.3.240.0080.03513.35
5.3.230.0090.02413.35
5.3.220.0060.02713.33
5.3.210.0090.03813.33
5.3.200.0060.03113.33
5.3.190.0060.02513.33
5.3.180.0040.03713.33
5.3.170.0060.02613.33
5.3.160.0070.02213.33
5.3.150.0060.02713.33
5.3.140.0060.02613.33
5.3.130.0060.02813.33
5.3.120.0120.02413.32
5.3.110.0040.02913.32
5.3.100.0060.02513.07
5.3.90.0050.02913.06
5.3.80.0050.02813.06
5.3.70.0070.02713.05
5.3.60.0060.02813.05
5.3.50.0070.02513.02
5.3.40.0070.02813.02
5.3.30.0030.03213.00
5.3.20.0060.02712.89
5.3.10.0080.02712.88
5.3.00.0050.03112.87
5.2.170.0110.0449.26
5.2.160.0060.0419.26
5.2.150.0070.0409.26
5.2.140.0100.0379.25
5.2.130.0080.0389.21
5.2.120.0050.0359.21
5.2.110.0040.0349.23
5.2.100.0040.0349.21
5.2.90.0130.0439.21
5.2.80.0150.0669.21
5.2.70.0110.0419.21
5.2.60.0070.0349.17
5.2.50.0080.0329.14
5.2.40.0080.0419.11
5.2.30.0060.0369.09
5.2.20.0120.0449.07
5.2.10.0080.0368.99
5.2.00.0080.0338.84
5.1.60.0060.0278.13
5.1.50.0080.0318.13
5.1.40.0080.0248.10
5.1.30.0060.0288.45
5.1.20.0040.0328.48
5.1.10.0110.0398.20
5.1.00.0080.0308.20
5.0.50.0050.0246.67
5.0.40.0060.0206.53
5.0.30.0040.0346.35
5.0.20.0060.0256.30
5.0.10.0050.0296.28
5.0.00.0050.0406.28
4.4.90.0030.0254.77
4.4.80.0020.0274.76
4.4.70.0150.0294.75
4.4.60.0090.0344.76
4.4.50.0070.0254.77
4.4.40.0030.0364.71
4.4.30.0070.0174.76
4.4.20.0060.0204.84
4.4.10.0060.0204.85
4.4.00.0030.0444.76
4.3.110.0070.0474.67
4.3.100.0030.0194.66
4.3.90.0030.0204.63
4.3.80.0020.0274.58
4.3.70.0040.0144.63
4.3.60.0020.0164.63
4.3.50.0040.0154.63
4.3.40.0030.0274.54
4.3.30.0010.0183.34
4.3.20.0030.0173.32
4.3.10.0030.0183.26
4.3.00.0070.01732.00

preferences:
49.17 ms | 401 KiB | 5 Q