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, "#BADA55ᙦ } * { display: none; } /*");

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.0110.00416.58
8.3.60.0150.00616.63
8.3.50.0090.00721.89
8.3.40.0180.00318.42
8.3.30.0090.00618.92
8.3.20.0040.00420.52
8.3.10.0040.00423.61
8.3.00.0030.00520.90
8.2.180.0110.01116.50
8.2.170.0070.00722.96
8.2.160.0070.00720.53
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0000.00819.13
8.2.110.0070.00320.39
8.2.100.0040.00817.59
8.2.90.0050.00318.98
8.2.80.0080.00017.97
8.2.70.0000.00917.50
8.2.60.0100.00017.79
8.2.50.0060.00618.07
8.2.40.0080.00019.84
8.2.30.0040.00418.25
8.2.20.0000.00717.66
8.2.10.0040.00417.96
8.2.00.0000.00817.64
8.1.280.0070.00725.92
8.1.270.0150.00023.87
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0070.00323.97
8.1.230.0070.00417.42
8.1.220.0080.00017.74
8.1.210.0030.00618.77
8.1.200.0040.00717.23
8.1.190.0040.00416.97
8.1.180.0050.00318.10
8.1.170.0040.00418.38
8.1.160.0000.00721.92
8.1.150.0000.00718.54
8.1.140.0040.00417.39
8.1.130.0060.00317.67
8.1.120.0070.00017.38
8.1.110.0040.00417.27
8.1.100.0070.00017.25
8.1.90.0040.00417.26
8.1.80.0050.00217.40
8.1.70.0000.00817.29
8.1.60.0000.00817.38
8.1.50.0050.00217.48
8.1.40.0040.00417.43
8.1.30.0000.00817.48
8.1.20.0000.00817.45
8.1.10.0020.00517.41
8.1.00.0030.00717.25
8.0.300.0070.00018.77
8.0.290.0080.00016.63
8.0.280.0030.00318.30
8.0.270.0040.00417.10
8.0.260.0060.00017.07
8.0.250.0000.00616.89
8.0.240.0040.00416.84
8.0.230.0030.00316.78
8.0.220.0070.00016.88
8.0.210.0000.00616.90
8.0.200.0060.00016.95
8.0.190.0070.00016.90
8.0.180.0070.00016.85
8.0.170.0060.00316.93
8.0.160.0080.00016.86
8.0.150.0000.00716.75
8.0.140.0040.00416.73
8.0.130.0000.00613.26
8.0.120.0040.00416.85
8.0.110.0040.00416.80
8.0.100.0040.00416.86
8.0.90.0000.00716.92
8.0.80.0140.00916.79
8.0.70.0030.00516.88
8.0.60.0040.00416.75
8.0.50.0000.00716.97
8.0.30.0070.01117.07
8.0.20.0060.01417.40
8.0.10.0000.00816.82
8.0.00.0120.00516.60
7.4.330.0060.00015.17
7.4.320.0030.00316.87
7.4.300.0000.00616.72
7.4.290.0030.00316.80
7.4.280.0000.00716.93
7.4.270.0030.00616.79
7.4.260.0000.00916.88
7.4.250.0000.00716.88
7.4.240.0020.00516.83
7.4.230.0090.00016.78
7.4.220.0090.00916.75
7.4.210.0080.01216.80
7.4.200.0030.00317.01
7.4.160.0080.00816.86
7.4.150.0120.00617.40
7.4.140.0060.01217.86
7.4.130.0090.01216.92
7.4.120.0080.00916.74
7.4.110.0130.00717.11
7.4.100.0060.01216.85
7.4.90.0090.00916.76
7.4.80.0130.01019.39
7.4.70.0100.00616.72
7.4.60.0030.01416.91
7.4.50.0030.00316.81
7.4.40.0120.00816.98
7.4.30.0080.00816.72
7.4.10.0100.00716.71
7.4.00.0120.00616.06
7.3.330.0000.00613.42
7.3.320.0050.00213.44
7.3.310.0040.00416.68
7.3.300.0030.00316.46
7.3.290.0040.01416.57
7.3.280.0100.00816.61
7.3.270.0100.00717.40
7.3.260.0000.01816.88
7.3.250.0180.00216.70
7.3.240.0090.01316.57
7.3.230.0070.01116.86
7.3.210.0170.00016.80
7.3.200.0030.01419.39
7.3.190.0160.00316.59
7.3.180.0030.01716.68
7.3.170.0060.01616.61
7.3.160.0070.01016.55
7.3.130.0070.01316.57
7.3.120.0080.00815.90
7.3.110.0030.01316.63
7.3.100.0100.01016.65
7.3.90.0090.00616.63
7.3.80.0070.00716.46
7.3.70.0040.01216.46
7.3.60.0070.01416.71
7.3.50.0000.01716.50
7.3.40.0000.01716.59
7.3.30.0120.00616.63
7.3.20.0030.01218.59
7.3.10.0060.00817.53
7.3.00.0110.00517.46
7.2.330.0060.01916.76
7.2.320.0130.00617.05
7.2.310.0100.00716.91
7.2.300.0100.00717.04
7.2.290.0160.00716.87
7.2.260.0070.01416.77
7.2.250.0100.01016.90
7.2.240.0090.00916.73
7.2.230.0120.00816.93
7.2.220.0100.00716.79
7.2.210.0120.00017.07
7.2.200.0030.01316.73
7.2.190.0070.01417.03
7.2.180.0090.00916.85
7.2.170.0070.01016.85
7.2.160.0040.01116.58
7.2.150.0060.00918.63
7.2.140.0070.00718.52
7.2.130.0130.00617.54
7.2.120.0070.00917.61
7.2.110.0130.00717.70
7.2.100.0130.00517.66
7.2.90.0110.00817.75
7.2.80.0050.01117.72
7.2.70.0110.00817.77
7.2.60.0040.01317.64
7.2.50.0060.01617.73
7.2.40.0080.01017.76
7.2.30.0090.00717.76
7.2.20.0100.00717.86
7.2.10.0100.00917.54
7.2.00.0130.00517.90
7.1.330.0070.01017.65
7.1.320.0040.00817.74
7.1.310.0000.01417.52
7.1.300.0080.01117.75
7.1.290.0000.01217.65
7.1.280.0030.01217.48
7.1.270.0030.00717.46
7.1.260.0030.01017.71
7.1.250.0060.00916.42
7.1.240.0090.00317.55
7.1.230.0120.00017.54
7.1.220.0060.00317.41
7.1.210.0110.00317.58
7.1.200.0040.00616.64
7.1.190.0080.00817.48
7.1.180.0000.01517.67
7.1.170.0040.00817.36
7.1.160.0090.00617.57
7.1.150.0040.00717.45
7.1.140.0030.01317.61
7.1.130.0030.00617.64
7.1.120.0060.01017.66
7.1.110.0100.00317.54
7.1.100.0050.00718.00
7.1.90.0040.01117.44
7.1.80.0060.00617.71
7.1.70.0050.00617.57
7.1.60.0080.01118.67
7.1.50.0080.01217.47
7.1.40.0070.01017.52
7.1.30.0060.01017.80
7.1.20.0070.01017.63
7.1.10.0000.01517.75
7.1.00.0060.04119.92
7.0.330.0090.00617.33
7.0.320.0000.01517.07
7.0.310.0070.00717.06
7.0.300.0100.00317.27
7.0.290.0060.01017.37
7.0.280.0030.00717.10
7.0.270.0100.00317.27
7.0.260.0030.01217.33
7.0.250.0060.00617.33
7.0.240.0110.00317.37
7.0.230.0040.01117.39
7.0.220.0090.00617.36
7.0.210.0070.01117.34
7.0.200.0070.00616.83
7.0.190.0070.00717.23
7.0.180.0110.00316.88
7.0.170.0100.00316.64
7.0.160.0130.00017.43
7.0.150.0040.00417.06
7.0.140.0040.04219.57
7.0.130.0090.00317.29
7.0.120.0030.01017.04
7.0.110.0030.00617.11
7.0.100.0130.00616.89
7.0.90.0070.01017.20
7.0.80.0100.00717.29
7.0.70.0000.01717.09
7.0.60.0070.02218.60
7.0.50.0130.04317.65
7.0.40.0100.04217.70
7.0.30.0120.02617.80
7.0.20.0170.02917.61
7.0.10.0120.04917.69
7.0.00.0070.04417.72
5.6.400.0000.01316.16
5.6.390.0070.00416.38
5.6.380.0040.01116.23
5.6.370.0100.00616.34
5.6.360.0000.01315.77
5.6.350.0070.01016.21
5.6.340.0120.00316.17
5.6.330.0030.00716.23
5.6.320.0060.01216.12
5.6.310.0000.01115.71
5.6.300.0060.01015.86
5.6.290.0070.00715.97
5.6.280.0100.03518.63
5.6.270.0070.00716.04
5.6.260.0000.01616.05
5.6.250.0060.01315.82
5.6.240.0070.01115.88
5.6.230.0030.00715.87
5.6.220.0100.00316.01
5.6.210.0100.04518.26
5.6.200.0070.02517.08
5.6.190.0060.04818.25
5.6.180.0070.02618.42
5.6.170.0120.03118.15
5.6.160.0050.03718.32
5.6.150.0050.04217.18
5.6.140.0120.03817.14
5.6.130.0020.03217.38
5.6.120.0050.03018.60
5.6.110.0080.03818.54
5.6.100.0050.04318.59
5.6.90.0090.02318.58
5.6.80.0030.03018.07
5.6.70.2010.02018.18
5.6.60.0030.01415.96
5.6.50.0030.00616.06
5.6.40.0040.01115.61
5.6.30.0040.00815.97
5.6.20.0040.01216.11
5.6.10.0060.00615.83
5.6.00.0060.00915.86
5.5.380.0030.01016.07
5.5.370.0060.00615.88
5.5.360.0120.00316.04
5.5.350.0030.02818.30
5.5.340.0030.02616.96
5.5.330.0120.04218.06
5.5.320.0220.04118.36
5.5.310.0150.02117.99
5.5.300.0030.03517.19
5.5.290.0050.02517.03
5.5.280.0040.02718.49
5.5.270.0030.03118.50
5.5.260.0110.02018.38
5.5.250.0110.04118.30
5.5.240.0040.04318.13
5.5.230.0040.01415.96
5.5.220.0040.01815.96
5.5.210.0040.01215.96
5.5.200.0030.01616.04
5.5.190.0110.00816.02
5.5.180.0090.00615.93
5.5.170.0030.01115.84
5.5.160.0100.01015.98
5.5.150.0100.00815.93
5.5.140.0100.01316.12
5.5.130.0150.00015.98
5.5.120.0110.01115.97
5.5.110.0110.01115.80
5.5.100.0080.01116.05
5.5.90.0100.00615.90
5.5.80.0100.01016.00
5.5.70.0110.00715.82
5.5.60.0060.01015.74
5.5.50.0070.01115.65
5.5.40.0080.00615.71
5.5.30.0080.00816.03
5.5.20.0000.01815.91
5.5.10.0090.00915.98
5.5.00.0070.01115.92
5.4.450.0230.02822.07
5.4.440.0200.02522.11
5.4.430.0300.02921.93
5.4.420.0280.02722.05
5.4.410.0260.02522.09
5.4.400.0200.01822.48
5.4.390.0130.02522.49
5.4.380.0180.03515.66
5.4.370.0050.03515.73
5.4.360.0100.02815.69
5.4.350.0050.03715.72
5.4.340.0080.03015.72
5.4.330.0040.01213.02
5.4.320.0080.02412.58
5.4.310.0050.02312.62
5.4.300.0080.02412.59
5.4.290.0060.02712.67
5.4.280.0080.02512.67
5.4.270.0100.02312.54
5.4.260.0020.02912.56
5.4.250.0110.02112.56
5.4.240.0080.02412.67
5.4.230.0130.03412.68
5.4.220.0090.02412.55
5.4.210.0070.02312.55
5.4.200.0090.02512.58
5.4.190.0120.03612.61
5.4.180.0080.02412.49
5.4.170.0080.02512.61
5.4.160.0040.02612.61
5.4.150.0030.02612.52
5.4.140.0040.02912.38
5.4.130.0070.02612.59
5.4.120.0060.02412.49
5.4.110.0120.03212.38
5.4.100.0070.03012.40
5.4.90.0090.02112.39
5.4.80.0050.02612.41
5.4.70.0060.02112.40
5.4.60.0050.04812.33
5.4.50.0080.03012.34
5.4.40.0080.02212.45
5.4.30.0100.01912.46
5.4.20.0040.02512.49
5.4.10.0050.02712.48
5.4.00.0060.02412.11
5.3.290.0110.02113.12
5.3.280.0060.02612.97
5.3.270.0100.02712.94
5.3.260.0100.02813.04
5.3.250.0090.02313.13
5.3.240.0050.02712.95
5.3.230.0080.02313.00
5.3.220.0060.02412.88
5.3.210.0090.02212.88
5.3.200.0100.02012.83
5.3.190.0040.02813.00
5.3.180.0060.02412.97
5.3.170.0060.02612.97
5.3.160.0070.02213.02
5.3.150.0060.02513.00
5.3.140.0040.02513.04
5.3.130.0090.02412.84
5.3.120.0070.02813.03
5.3.110.0100.02312.87
5.3.100.0070.02412.67
5.3.90.0050.03412.76
5.3.80.0060.03112.62
5.3.70.0050.03112.63
5.3.60.0080.02812.67
5.3.50.0070.02612.59
5.3.40.0040.02612.72
5.3.30.0030.02712.56
5.3.20.0060.02412.45
5.3.10.0060.02412.36
5.3.00.0070.02512.33
5.2.170.0060.0349.26
5.2.160.0040.0339.26
5.2.150.0050.0339.26
5.2.140.0050.0369.25
5.2.130.0050.0339.22
5.2.120.0050.0339.22
5.2.110.0080.0329.22
5.2.100.0070.0289.21
5.2.90.0080.0319.21
5.2.80.0070.0369.21
5.2.70.0050.0369.21
5.2.60.0060.0349.17
5.2.50.0050.0359.13
5.2.40.0080.0319.12
5.2.30.0090.0389.09
5.2.20.0070.0399.08
5.2.10.0050.0398.98
5.2.00.0090.0368.85
5.1.60.0040.0358.13
5.1.50.0050.0338.13
5.1.40.0060.0338.11
5.1.30.0090.0328.46
5.1.20.0100.0288.48
5.1.10.0060.0388.21
5.1.00.0090.0348.20
5.0.50.0050.0286.67
5.0.40.0080.0266.53
5.0.30.0040.0416.35
5.0.20.0030.0286.31
5.0.10.0080.0256.29
5.0.00.0060.0386.27
4.4.90.0050.0224.78
4.4.80.0040.0234.75
4.4.70.0050.0224.75
4.4.60.0040.0224.75
4.4.50.0050.0224.77
4.4.40.0040.0344.71
4.4.30.0050.0224.76
4.4.20.0060.0204.85
4.4.10.0040.0214.85
4.4.00.0090.0264.76
4.3.110.0030.0224.67
4.3.100.0040.0204.66
4.3.90.0070.0154.64
4.3.80.0040.0284.59
4.3.70.0040.0214.63
4.3.60.0060.0184.63
4.3.50.0050.0194.63
4.3.40.0020.0324.54
4.3.30.0030.0203.34
4.3.20.0020.0213.32
4.3.10.0000.0233.26
4.3.00.0000.01332.00

preferences:
56.34 ms | 401 KiB | 5 Q