3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $version="v1.2.124.0bcd4d"; $fullVersion = $version; $version = trim($version); if (null === $fullVersion) { $fullVersion = $version; } // ignore aliases and just assume the alias is required instead of the source if (preg_match('{^([^,\s]+) +as +([^,\s]+)$}', $version, $match)) { $version = $match[1]; } // ignore build metadata if (preg_match('{^([^,\s+]+)\+[^\s]+$}', $version, $match)) { $version = $match[1]; } // match master-like branches if (preg_match('{^(?:dev-)?(?:master|trunk|default)$}i', $version)) { return '9999999-dev'; } if ('dev-' === strtolower(substr($version, 0, 4))) { return 'dev-'.substr($version, 4); } print_r($fullVersion); // match classical versioning if (preg_match('{^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?$}i', $version, $matches)) { $version = $matches[1] .(!empty($matches[2]) ? $matches[2] : '.0') .(!empty($matches[3]) ? $matches[3] : '.0') .(!empty($matches[4]) ? $matches[4] : '.0'); $index = 5; } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)$}i', $version, $matches)) { // match date-based versioning $version = preg_replace('{\D}', '-', $matches[1]); $index = 2; } elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?$}i', $version, $matches)) { $version = $matches[1] .(!empty($matches[2]) ? $matches[2] : '.0') .(!empty($matches[3]) ? $matches[3] : '.0') .(!empty($matches[4]) ? $matches[4] : '.0'); $index = 5; } // add version modifiers if a version was matched if (isset($index)) { if (!empty($matches[$index])) { if ('stable' === $matches[$index]) { return $version; } $version .= '-' . $this->expandStability($matches[$index]) . (!empty($matches[$index+1]) ? $matches[$index+1] : ''); } if (!empty($matches[$index+2])) { $version .= '-dev'; } return $version; } // match dev branches if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) { try { return $this->normalizeBranch($match[1]); } catch (\Exception $e) { } } $extraMessage = ''; if (preg_match('{ +as +'.preg_quote($version).'$}', $fullVersion)) { $extraMessage = ' in "'.$fullVersion.'", the alias must be an exact version'; } elseif (preg_match('{^'.preg_quote($version).' +as +}', $fullVersion)) { $extraMessage = ' in "'.$fullVersion.'", the alias source must be an exact version, if it is a branch name you should prefix it with dev-'; } throw new \UnexpectedValueException('Invalid version string "'.$version.'"'.$extraMessage);
Output for 7.0.0 - 7.3.0alpha1
v1.2.124.0bcd4d Fatal error: Uncaught UnexpectedValueException: Invalid version string "v1.2.124.0bcd4d" in /in/dhVnE:75 Stack trace: #0 {main} thrown in /in/dhVnE on line 75
Process exited with code 255.
Output for 5.3.0 - 5.6.28
v1.2.124.0bcd4d Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Invalid version string "v1.2.124.0bcd4d"' in /in/dhVnE:75 Stack trace: #0 {main} thrown in /in/dhVnE on line 75
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/dhVnE on line 65 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/dhVnE on line 75 v1.2.124.0bcd4d Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Invalid version string "v1.2.124.0bcd4d"' in /in/dhVnE:75 Stack trace: #0 {main} thrown in /in/dhVnE on line 75
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/dhVnE on line 65 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/dhVnE on line 75 v1.2.124.0bcd4d Fatal error: Class 'UnexpectedValueException' not found in /in/dhVnE on line 75
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/dhVnE on line 63
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '{' in /in/dhVnE on line 63
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/dhVnE on line 63
Process exited with code 255.