3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * 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 value is less than 256 !preg_match("/^\w$/", $currChar) && //Character is not alphanumeric (underscore is considered safe too) !in_array($currChar, $immuneChars) //Character is not immune ) { $result .= escapeCSSCharacter($currChar); } else { $result .= $currChar; } } return $result; } $colorRule = "color: " . escapeCSSValue("#BADA55;*{display:none;}", array("#") . ";"; //Will be obviously broken, but will not break the rest of the document. echo $colorRule;

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)
5.4.300.0060.05212.53
5.4.290.0060.04512.52
5.4.280.0100.05012.43
5.4.270.0090.03812.42
5.4.260.0110.05412.43
5.4.250.0140.04912.42
5.4.240.0050.04512.42
5.4.230.0070.04712.42
5.4.220.0090.03912.42
5.4.210.0110.04112.41
5.4.200.0050.04212.42
5.4.190.0090.04112.41
5.4.180.0100.04712.41
5.4.170.0080.03512.42
5.4.160.0090.03812.41
5.4.150.0100.03412.41
5.4.140.0090.03512.10
5.4.130.0100.03212.08
5.4.120.0060.03812.04
5.4.110.0110.04112.04
5.4.100.0100.04812.04
5.4.90.0140.04712.04
5.4.80.0080.05112.04
5.4.70.0080.03712.04
5.4.60.0060.03612.04
5.4.50.0080.03712.04
5.4.40.0100.04612.02
5.4.30.0090.05112.03
5.4.20.0080.04112.02
5.4.10.0090.03512.03
5.4.00.0070.04011.52
5.3.280.0040.04412.71
5.3.270.0080.04112.72
5.3.260.0060.04312.72
5.3.250.0060.04112.71
5.3.240.0110.04612.72
5.3.230.0070.05212.71
5.3.220.0060.04512.68
5.3.210.0080.04112.68
5.3.200.0060.03812.68
5.3.190.0110.03812.68
5.3.180.0080.04812.67
5.3.170.0060.04312.67
5.3.160.0040.04312.67
5.3.150.0110.03512.67
5.3.140.0070.03912.66
5.3.130.0100.04212.65
5.3.120.0070.04812.66
5.3.110.0070.05812.66
5.3.100.0070.05212.14
5.3.90.0110.03912.12
5.3.80.0120.04712.12
5.3.70.0080.05212.12
5.3.60.0160.05712.10
5.3.50.0100.05012.05
5.3.40.0140.04412.04
5.3.30.0140.04412.00
5.3.20.0060.04911.79
5.3.10.0240.07011.75
5.3.00.0140.09311.74

preferences:
142.3 ms | 1386 KiB | 7 Q