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); $ESCAPE_PROPERTIES = true; /** * 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_COLOR, "<script src='evil.js'>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.40.0110.00418.60
8.3.30.0070.00718.95
8.3.20.0050.00220.16
8.3.10.0080.00023.52
8.3.00.0080.00021.01
8.2.170.0090.00622.96
8.2.160.0120.00820.43
8.2.150.0080.00024.18
8.2.140.0110.00424.66
8.2.130.0050.00326.16
8.2.120.0080.00020.73
8.2.110.0220.00022.17
8.2.100.0000.01217.72
8.2.90.0000.00819.15
8.2.80.0090.00017.97
8.2.70.0050.00317.50
8.2.60.0110.00017.74
8.2.50.0060.00318.07
8.2.40.0030.00618.03
8.2.30.0060.00318.23
8.2.20.0000.00717.57
8.2.10.0070.00017.95
8.2.00.0000.00817.59
8.1.270.0040.00423.96
8.1.260.0040.00426.35
8.1.250.0030.00528.09
8.1.240.0140.00723.96
8.1.230.0080.00319.00
8.1.220.0000.00817.74
8.1.210.0000.00818.77
8.1.200.0060.00317.11
8.1.190.0040.00417.11
8.1.180.0000.00818.10
8.1.170.0060.00318.52
8.1.160.0050.00322.02
8.1.150.0000.00718.45
8.1.140.0000.00817.28
8.1.130.0060.00317.72
8.1.120.0000.00817.41
8.1.110.0000.00817.39
8.1.100.0000.00717.39
8.1.90.0040.00417.43
8.1.80.0000.00717.38
8.1.70.0040.00417.34
8.1.60.0030.00517.50
8.1.50.0000.00817.45
8.1.40.0040.00417.26
8.1.30.0040.00517.52
8.1.20.0080.00017.55
8.1.10.0060.00317.27
8.1.00.0040.00817.40
8.0.300.0050.00218.77
8.0.290.0000.00716.58
8.0.280.0030.00318.35
8.0.270.0000.00717.16
8.0.260.0030.00317.16
8.0.250.0040.00416.96
8.0.240.0030.00316.88
8.0.230.0070.00016.88
8.0.220.0000.00716.86
8.0.210.0000.00716.77
8.0.200.0030.00316.89
8.0.190.0030.00516.81
8.0.180.0070.00016.92
8.0.170.0060.00316.90
8.0.160.0030.00516.86
8.0.150.0040.00416.71
8.0.140.0000.00716.80
8.0.130.0000.00513.23
8.0.120.0040.00416.75
8.0.110.0070.00016.82
8.0.100.0030.00516.88
8.0.90.0040.00416.85
8.0.80.0080.00816.91
8.0.70.0040.00416.89
8.0.60.0070.00016.81
8.0.50.0040.00416.84
8.0.30.0130.01116.91
8.0.20.0090.01017.40
8.0.10.0070.00017.05
8.0.00.0050.01316.58
7.4.330.0050.00015.03
7.4.320.0070.00016.81
7.4.300.0030.00316.75
7.4.290.0030.00316.72
7.4.280.0060.00316.93
7.4.270.0000.00716.91
7.4.260.0000.00816.89
7.4.250.0050.00216.85
7.4.240.0030.00516.85
7.4.230.0070.00016.63
7.4.220.0090.00916.90
7.4.210.0090.00616.73
7.4.200.0030.00516.87
7.4.160.0080.00816.87
7.4.150.0120.00917.40
7.4.140.0100.01117.86
7.4.130.0120.00516.84
7.4.120.0100.00616.88
7.4.110.0070.01716.80
7.4.100.0090.00916.80
7.4.90.0120.01216.78
7.4.80.0130.00719.39
7.4.70.0100.00716.65
7.4.60.0130.01016.99
7.4.50.0030.00316.45
7.4.40.0140.00316.54
7.4.30.0090.00916.81
7.4.00.0070.01015.42
7.3.330.0000.00613.47
7.3.320.0030.00313.68
7.3.310.0070.00016.55
7.3.300.0040.00416.56
7.3.290.0040.01116.62
7.3.280.0100.00816.58
7.3.270.0140.00417.40
7.3.260.0120.00616.79
7.3.250.0090.00916.64
7.3.240.0060.01216.63
7.3.230.0090.00916.62
7.3.210.0040.01317.00
7.3.200.0070.01319.39
7.3.190.0180.00416.99
7.3.180.0110.00516.66
7.3.170.0090.00916.86
7.3.160.0130.00316.55
7.3.120.0040.00715.23
7.2.330.0120.00916.93
7.2.320.0170.00017.01
7.2.310.0120.00617.05
7.2.300.0110.00616.74
7.2.290.0100.01316.83
7.2.60.0050.00817.16
7.1.200.0100.00315.60
7.1.100.0060.00918.17
7.1.70.0030.01017.39
7.1.60.0130.01019.70
7.1.50.0100.01317.25
7.1.00.0100.07022.41
7.0.200.0040.00417.04
7.0.140.0100.06722.02
7.0.60.0100.03719.88
7.0.50.0070.06317.94
7.0.40.0030.09020.23
7.0.30.0400.04720.14
7.0.20.0170.07720.09
7.0.10.0030.08020.26
7.0.00.0030.05720.20
5.6.280.0100.06720.85
5.6.210.0100.07720.65
5.6.200.0070.04718.19
5.6.190.0200.07320.55
5.6.180.0170.05320.42
5.6.170.0230.04320.56
5.6.160.0170.07320.45
5.6.150.0200.06718.28
5.6.140.0000.09018.21
5.6.130.0070.08018.17
5.6.120.0270.06721.01
5.6.110.0170.07321.15
5.6.100.0170.07721.04
5.6.90.0000.07721.11
5.6.80.0000.08720.41
5.6.70.4230.02720.40
5.5.350.0270.08720.44
5.5.340.0100.07318.00
5.5.330.0000.05720.40
5.5.320.0330.07320.27
5.5.310.0270.04320.25
5.5.300.0030.07717.94
5.5.290.0070.06718.05
5.5.280.0000.04720.91
5.5.270.0100.07320.87
5.5.260.0000.09320.67
5.5.250.0170.07320.61
5.5.240.0300.06720.22
5.4.450.0100.05331.20
5.4.440.0370.04331.20
5.4.430.0200.04731.20
5.4.420.0170.04731.20
5.4.410.0200.03031.20
5.4.400.0130.04332.00
5.4.390.0070.03732.00
5.4.380.0300.05318.75
5.4.370.0370.05018.59
5.4.360.0470.04318.77
5.4.350.0270.05318.58
5.4.340.0300.05318.59
5.4.320.0060.04312.53
5.4.310.0080.04012.53
5.4.300.0090.04912.53
5.4.290.0080.04612.53
5.4.280.0090.03912.43
5.4.270.0090.04312.43
5.4.260.0040.05112.42
5.4.250.0090.04712.43
5.4.240.0130.04112.42
5.4.230.0090.04412.42
5.4.220.0080.04012.42
5.4.210.0080.03612.42
5.4.200.0100.03712.42
5.4.190.0120.03312.42
5.4.180.0090.03612.41
5.4.170.0050.04012.43
5.4.160.0060.03912.42
5.4.150.0060.03912.42
5.4.140.0060.03912.10
5.4.130.0040.03912.09
5.4.120.0050.03812.05
5.4.110.0080.03412.04
5.4.100.0120.03212.04
5.4.90.0090.03612.04
5.4.80.0050.04112.04
5.4.70.0070.03612.04
5.4.60.0070.03912.04
5.4.50.0040.03912.04
5.4.40.0060.03812.03
5.4.30.0090.03712.02
5.4.20.0090.03712.02
5.4.10.0090.03612.02
5.4.00.0160.05111.51
5.3.290.0050.04012.80
5.3.280.0050.04212.71
5.3.270.0140.04412.72
5.3.260.0090.04112.73
5.3.250.0100.03812.72
5.3.240.0080.04212.73
5.3.230.0090.04012.71
5.3.220.0090.04412.69
5.3.210.0130.03812.69
5.3.200.0070.04112.68
5.3.190.0090.04312.68
5.3.180.0120.03512.69
5.3.170.0090.03912.68
5.3.160.0060.04712.69
5.3.150.0070.04412.69
5.3.140.0090.03712.68
5.3.130.0080.04012.67
5.3.120.0100.04212.67
5.3.110.0070.05212.67
5.3.100.0040.05312.15
5.3.90.0080.05112.13
5.3.80.0060.04912.13
5.3.70.0070.04812.13
5.3.60.0080.04812.12
5.3.50.0070.04812.06
5.3.40.0090.03712.06
5.3.30.0080.04112.02
5.3.20.0070.03911.80
5.3.10.0090.03611.76
5.3.00.0080.04111.77
5.2.170.0070.0379.26
5.2.160.0070.0409.27
5.2.150.0080.0379.26
5.2.140.0100.0379.25
5.2.130.0070.0339.22
5.2.120.0060.0449.21
5.2.110.0060.0359.23
5.2.100.0140.0329.21
5.2.90.0100.0369.21
5.2.80.0060.0329.21
5.2.70.0070.0319.21
5.2.60.0060.0329.17
5.2.50.0050.0329.14
5.2.40.0060.0299.12
5.2.30.0080.0289.09
5.2.20.0020.0329.08
5.2.10.0040.0358.98
5.2.00.0080.0308.84
5.1.60.0050.0298.13
5.1.50.0080.0328.13
5.1.40.0050.0358.11
5.1.30.0070.0338.46
5.1.20.0040.0308.48
5.1.10.0060.0358.21
5.1.00.0070.0358.20
5.0.50.0040.0276.68
5.0.40.0030.0276.53
5.0.30.0050.0456.35
5.0.20.0040.0286.31
5.0.10.0080.0276.28
5.0.00.0040.0396.28
4.4.90.0030.0224.78
4.4.80.0040.0204.75
4.4.70.0040.0184.75
4.4.60.0080.0154.76
4.4.50.0130.0464.77
4.4.40.0050.0424.71
4.4.30.0090.0474.76
4.4.20.0080.0174.84
4.4.10.0040.0174.85
4.4.00.0050.0304.76
4.3.110.0050.0184.67
4.3.100.0040.0204.66
4.3.90.0020.0194.64
4.3.80.0050.0264.59
4.3.70.0050.0154.63
4.3.60.0050.0184.63
4.3.50.0070.0224.63
4.3.40.0010.0274.54
4.3.30.0010.0183.34
4.3.20.0040.0153.32
4.3.10.0010.0183.26
4.3.00.0070.01732.00

preferences:
39.37 ms | 400 KiB | 5 Q