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.0170.00316.75
8.3.60.0150.00318.32
8.3.50.0210.00822.01
8.3.40.0090.00618.54
8.3.30.0120.00318.91
8.3.20.0040.00420.25
8.3.10.0000.00823.53
8.3.00.0040.00420.89
8.2.180.0100.01316.37
8.2.170.0170.00322.96
8.2.160.0070.00720.41
8.2.150.0000.00824.18
8.2.140.0030.00624.66
8.2.130.0080.00026.16
8.2.120.0040.00420.79
8.2.110.0100.00020.54
8.2.100.0070.00417.68
8.2.90.0030.00518.80
8.2.80.0030.00517.97
8.2.70.0000.00817.38
8.2.60.0030.00617.80
8.2.50.0040.00418.07
8.2.40.0040.00419.72
8.2.30.0040.00418.03
8.2.20.0020.00517.55
8.2.10.0040.00417.88
8.2.00.0070.00417.46
8.1.280.0090.00625.92
8.1.270.0040.00423.87
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0000.00923.79
8.1.230.0060.00617.42
8.1.220.0030.00617.74
8.1.210.0040.00418.77
8.1.200.0100.00017.22
8.1.190.0050.00316.98
8.1.180.0050.00318.10
8.1.170.0040.00418.39
8.1.160.0000.00821.97
8.1.150.0000.00818.48
8.1.140.0050.00217.34
8.1.130.0000.00717.84
8.1.120.0000.00717.29
8.1.110.0000.00917.38
8.1.100.0030.00517.34
8.1.90.0030.00317.37
8.1.80.0050.00317.37
8.1.70.0000.00717.37
8.1.60.0000.00917.49
8.1.50.0040.00417.49
8.1.40.0000.00817.46
8.1.30.0050.00317.51
8.1.20.0030.00617.42
8.1.10.0000.00817.30
8.1.00.0090.00317.30
8.0.300.0000.00718.77
8.0.290.0000.00816.58
8.0.280.0000.00718.46
8.0.270.0040.00417.23
8.0.260.0000.00617.18
8.0.250.0020.00516.92
8.0.240.0040.00416.95
8.0.230.0040.00316.84
8.0.220.0040.00416.76
8.0.210.0050.00216.77
8.0.200.0000.00716.92
8.0.190.0040.00416.99
8.0.180.0000.00816.95
8.0.170.0080.00016.92
8.0.160.0060.00316.98
8.0.150.0000.00716.79
8.0.140.0090.00316.80
8.0.130.0060.00013.30
8.0.120.0030.00516.84
8.0.110.0080.00016.82
8.0.100.0050.00316.75
8.0.90.0040.00416.74
8.0.80.0090.00616.89
8.0.70.0060.00316.75
8.0.60.0000.00716.76
8.0.50.0000.00816.73
8.0.30.0140.00517.06
8.0.20.0110.01017.40
8.0.10.0070.00016.99
8.0.00.0080.01216.69
7.4.330.0060.00015.12
7.4.320.0030.00316.71
7.4.300.0030.00316.80
7.4.290.0000.00716.88
7.4.280.0080.00016.79
7.4.270.0050.00316.82
7.4.260.0000.00716.87
7.4.250.0050.00316.83
7.4.240.0070.00016.76
7.4.230.0000.00716.70
7.4.220.0100.01316.96
7.4.210.0040.01116.81
7.4.200.0000.00716.96
7.4.160.0130.00316.93
7.4.150.0120.00617.40
7.4.140.0080.01117.86
7.4.130.0110.00616.83
7.4.120.0080.00816.84
7.4.110.0130.00616.98
7.4.100.0110.00916.76
7.4.90.0130.00416.80
7.4.80.0130.00719.39
7.4.70.0100.00716.91
7.4.60.0140.00416.65
7.4.50.0000.00616.66
7.4.40.0060.01016.93
7.4.30.0140.00316.86
7.4.10.0100.00315.19
7.4.00.0100.00915.20
7.3.330.0060.00013.52
7.3.320.0000.00713.58
7.3.310.0000.00716.55
7.3.300.0000.00716.45
7.3.290.0060.00916.51
7.3.280.0050.01116.58
7.3.270.0120.00617.40
7.3.260.0140.00316.65
7.3.250.0080.01416.78
7.3.240.0160.00916.94
7.3.230.0070.01416.60
7.3.210.0150.00916.84
7.3.200.0110.00619.39
7.3.190.0110.00916.91
7.3.180.0100.00716.83
7.3.170.0130.01016.91
7.3.160.0120.00416.57
7.3.130.0030.01315.40
7.3.120.0060.01215.20
7.3.110.0070.01015.31
7.3.100.0080.00615.16
7.3.90.0080.00415.00
7.3.80.0020.01115.30
7.3.70.0060.00515.20
7.3.60.0050.01015.26
7.3.50.0060.00615.10
7.3.40.0070.00415.17
7.3.30.0080.00715.22
7.3.20.0050.01016.90
7.3.10.0060.00816.78
7.3.00.0050.00716.85
7.2.330.0160.00616.93
7.2.320.0080.01416.89
7.2.310.0070.01117.05
7.2.300.0090.00916.96
7.2.290.0120.00916.93
7.2.260.0110.00715.31
7.2.250.0130.00715.26
7.2.240.0050.01215.16
7.2.230.0080.00915.35
7.2.220.0020.01015.21
7.2.210.0030.01215.20
7.2.200.0030.01015.37
7.2.190.0030.01415.35
7.2.180.0060.00515.37
7.2.170.0060.00815.21
7.2.160.0040.01115.29
7.2.150.0040.01117.09
7.2.140.0070.01117.07
7.2.130.0000.01317.06
7.2.120.0060.00617.04
7.2.110.0080.00817.27
7.2.100.0040.00917.26
7.2.90.0110.00317.15
7.2.80.0080.00517.05
7.2.70.0070.00817.08
7.2.60.0060.00717.21
7.2.50.0070.00917.12
7.2.40.0060.00617.20
7.2.30.0030.01117.28
7.2.20.0050.00817.14
7.2.10.0050.01017.26
7.2.00.0050.01117.83
7.1.330.0030.01116.10
7.1.320.0020.00815.88
7.1.310.0100.00516.06
7.1.300.0040.00916.04
7.1.290.0020.01016.07
7.1.280.0030.01215.91
7.1.270.0070.00916.11
7.1.260.0040.01015.82
7.1.250.0030.01016.00
7.1.240.0070.00715.56
7.1.230.0090.00616.16
7.1.220.0070.00716.02
7.1.210.0120.00016.18
7.1.200.0030.00616.07
7.1.190.0040.00816.00
7.1.180.0070.00715.95
7.1.170.0130.00016.15
7.1.160.0030.00615.92
7.1.150.0100.00315.75
7.1.140.0060.00315.91
7.1.130.0060.00616.05
7.1.120.0070.00315.85
7.1.110.0090.00616.14
7.1.100.0060.00717.20
7.1.90.0000.01316.14
7.1.80.0140.00016.07
7.1.70.0050.01116.61
7.1.60.0080.00817.95
7.1.50.0030.01416.70
7.1.40.0000.01416.12
7.1.30.0040.01115.70
7.1.20.0000.00915.96
7.1.10.0040.01116.05
7.1.00.0050.04119.17
7.0.330.0060.00615.67
7.0.320.0060.00315.61
7.0.310.0000.01515.38
7.0.300.0070.01015.54
7.0.290.0040.00415.39
7.0.280.0060.01015.50
7.0.270.0030.00915.41
7.0.260.0040.00415.66
7.0.250.0060.00915.83
7.0.240.0100.00015.70
7.0.230.0000.01115.47
7.0.220.0060.00615.78
7.0.210.0090.00915.85
7.0.200.0040.00616.15
7.0.190.0100.00315.54
7.0.180.0060.00615.49
7.0.170.0000.00815.79
7.0.160.0070.01015.63
7.0.150.0060.00615.54
7.0.140.0030.04118.70
7.0.130.0060.00615.47
7.0.120.0030.00615.70
7.0.110.0000.00815.87
7.0.100.0040.00815.55
7.0.90.0060.00615.67
7.0.80.0070.01015.80
7.0.70.0000.00915.70
7.0.60.0070.03817.74
7.0.50.0070.02716.83
7.0.40.0090.04616.82
7.0.30.0120.03216.96
7.0.20.0170.04416.92
7.0.10.0020.02816.98
7.0.00.0050.02916.92
5.6.400.0060.00314.71
5.6.390.0030.01014.64
5.6.380.0080.00014.10
5.6.370.0030.00614.12
5.6.360.0040.00714.90
5.6.350.0070.00414.57
5.6.340.0030.01314.64
5.6.330.0060.00514.86
5.6.320.0110.00314.26
5.6.310.0030.01014.42
5.6.300.0040.01114.66
5.6.290.0030.00914.88
5.6.280.0020.04217.85
5.6.270.0110.00314.67
5.6.260.0030.00914.63
5.6.250.0060.01014.42
5.6.240.0060.01314.53
5.6.230.0100.00714.54
5.6.220.0040.00814.29
5.6.210.0080.02217.52
5.6.200.0060.04616.40
5.6.190.0050.04317.53
5.6.180.0150.03617.59
5.6.170.0100.02917.63
5.6.160.0050.03017.45
5.6.150.0040.04216.33
5.6.140.0100.04316.50
5.6.130.0070.02216.38
5.6.120.0110.01817.64
5.6.110.0040.03517.86
5.6.100.0060.04317.73
5.6.90.0100.04017.56
5.6.80.0110.02817.54
5.6.70.1990.02217.50
5.6.60.0090.00314.43
5.6.50.0060.00614.35
5.6.40.0060.00914.34
5.6.30.0060.00314.30
5.6.20.0030.00914.48
5.6.10.0090.00614.48
5.6.00.0120.00014.16
5.5.380.0090.00614.79
5.5.370.0110.00714.69
5.5.360.0070.00714.60
5.5.350.0130.04717.41
5.5.340.0060.04816.06
5.5.330.0020.02917.57
5.5.320.0090.03117.26
5.5.310.0150.03417.49
5.5.300.0020.03716.40
5.5.290.0030.03516.13
5.5.280.0040.03017.66
5.5.270.0140.03517.79
5.5.260.0050.02617.67
5.5.250.0030.02317.63
5.5.240.0130.04517.37
5.5.230.0090.00614.26
5.5.220.0070.00714.54
5.5.210.0070.00714.62
5.5.200.0000.01214.53
5.5.190.0060.00914.38
5.5.180.0090.00014.64
5.5.170.0080.00314.59
5.5.160.0030.01314.55
5.5.150.0080.00414.14
5.5.140.0040.00814.55
5.5.130.0040.00814.51
5.5.120.0070.00714.21
5.5.110.0070.00414.63
5.5.100.0000.01514.48
5.5.90.0070.00714.41
5.5.80.0060.00914.48
5.5.70.0080.00614.46
5.5.60.0070.00314.56
5.5.50.0030.01314.39
5.5.40.0070.00714.39
5.5.30.0040.00814.40
5.5.20.0000.01114.71
5.5.10.0070.00714.69
5.5.00.0000.01214.51
5.4.450.0270.02721.32
5.4.440.0180.02021.27
5.4.430.0270.01721.22
5.4.420.0120.02021.33
5.4.410.0210.01821.33
5.4.400.0130.02421.59
5.4.390.0080.02421.66
5.4.380.0100.03214.84
5.4.370.0120.02715.02
5.4.360.0120.02514.99
5.4.350.0080.02914.85
5.4.340.0090.02714.96
5.4.330.0070.00711.43
5.4.320.0060.02611.98
5.4.310.0020.02611.85
5.4.300.0070.02311.87
5.4.290.0050.03011.72
5.4.280.0070.02511.99
5.4.270.0080.02511.78
5.4.260.0060.02611.70
5.4.250.0090.02911.87
5.4.240.0100.03811.76
5.4.230.0030.03711.86
5.4.220.0110.05211.64
5.4.210.0100.04011.98
5.4.200.0100.03211.88
5.4.190.0100.02311.68
5.4.180.0040.03311.93
5.4.170.0050.02711.76
5.4.160.0090.02211.64
5.4.150.0070.02411.75
5.4.140.0060.03011.75
5.4.130.0070.02411.62
5.4.120.0070.02911.68
5.4.110.0080.02611.78
5.4.100.0050.02611.75
5.4.90.0090.02411.61
5.4.80.0070.02611.64
5.4.70.0090.03011.66
5.4.60.0090.02911.62
5.4.50.0090.03011.49
5.4.40.0070.02711.48
5.4.30.0110.02611.71
5.4.20.0050.03211.72
5.4.10.0060.03411.57
5.4.00.0040.03211.46
5.3.290.0040.02211.84
5.3.280.0080.02611.79
5.3.270.0070.03011.79
5.3.260.0060.02911.79
5.3.250.0040.02911.84
5.3.240.0060.02711.79
5.3.230.0040.03111.79
5.3.220.0050.02911.78
5.3.210.0050.02811.77
5.3.200.0070.02611.77
5.3.190.0100.02611.78
5.3.180.0060.02711.77
5.3.170.0070.02811.77
5.3.160.0090.02811.77
5.3.150.0060.02811.77
5.3.140.0040.03011.77
5.3.130.0090.02711.77
5.3.120.0060.03011.77
5.3.110.0060.02911.77
5.3.100.0060.02511.51
5.3.90.0040.02911.50
5.3.80.0060.02911.50
5.3.70.0130.02111.50
5.3.60.0040.03111.49
5.3.50.0040.03011.46
5.3.40.0080.02711.46
5.3.30.0050.02611.44
5.3.20.0050.02611.33
5.3.10.0020.02911.31
5.3.00.0070.02711.31
5.2.170.0070.0429.26
5.2.160.0070.0399.26
5.2.150.0080.0409.26
5.2.140.0030.0449.26
5.2.130.0030.0419.21
5.2.120.0050.0409.21
5.2.110.0050.0399.23
5.2.100.0060.0399.22
5.2.90.0030.0439.22
5.2.80.0060.0429.21
5.2.70.0080.0409.21
5.2.60.0090.0399.17
5.2.50.0040.0459.14
5.2.40.0070.0379.12
5.2.30.0040.0439.09
5.2.20.0070.0379.08
5.2.10.0050.0388.98
5.2.00.0050.0418.84
5.1.60.0040.0358.13
5.1.50.0060.0328.13
5.1.40.0090.0308.11
5.1.30.0090.0328.46
5.1.20.0060.0358.48
5.1.10.0060.0348.20
5.1.00.0080.0328.20
5.0.50.0100.0216.67
5.0.40.0060.0256.53
5.0.30.0050.0396.35
5.0.20.0150.0166.30
5.0.10.0040.0286.28
5.0.00.0080.0366.27
4.4.90.0050.0214.78
4.4.80.0030.0214.76
4.4.70.0070.0174.75
4.4.60.0050.0194.75
4.4.50.0030.0224.77
4.4.40.0050.0324.70
4.4.30.0040.0214.76
4.4.20.0050.0204.85
4.4.10.0050.0194.85
4.4.00.0040.0324.75
4.3.110.0020.0244.67
4.3.100.0040.0204.66
4.3.90.0060.0184.64
4.3.80.0060.0284.58
4.3.70.0030.0204.63
4.3.60.0040.0194.63
4.3.50.0050.0194.63
4.3.40.0100.0244.53
4.3.30.0040.0203.34
4.3.20.0080.0193.32
4.3.10.0090.0163.26
4.3.00.0070.01332.00

preferences:
30.13 ms | 401 KiB | 5 Q