3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $version = '5.5.58-0ubuntu0.14.04.1'; echo '<pre>'; var_dump(preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts)); if (!preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts)) { echo "RegEx failed on " . $version . PHP_EOL; } else { echo "RegEx extracted version parts" . PHP_EOL; var_dump($versionParts); } function errorValue($error) { return defined($error) ? constant($error) : $error; } $errors = array( 'PREG_NO_ERROR', 'PREG_INTERNAL_ERROR', 'PREG_BACKTRACK_LIMIT_ERROR', 'PREG_RECURSION_LIMIT_ERROR', 'PREG_BAD_UTF8_ERROR', 'PREG_BAD_UTF8_OFFSET_ERROR', 'PREG_JIT_STACKLIMIT_ERROR' ); $pregErrors = array_combine( array_map('errorValue', $errors), $errors ); echo $pregErrors[preg_last_error()] . PHP_EOL; echo '</pre>';
based on d4TAW
Output for 5.2.0 - 5.6.30, hhvm-3.10.1 - 3.22.0, 7.0.0 - 7.2.6
<pre>int(1) RegEx extracted version parts array(7) { [0]=> string(6) "5.5.58" ["major"]=> string(1) "5" [1]=> string(1) "5" ["minor"]=> string(1) "5" [2]=> string(1) "5" ["patch"]=> string(2) "58" [3]=> string(2) "58" } PREG_NO_ERROR </pre>
Output for 5.0.2 - 5.1.6
<pre>int(1) RegEx extracted version parts array(7) { [0]=> string(6) "5.5.58" ["major"]=> string(1) "5" [1]=> string(1) "5" ["minor"]=> string(1) "5" [2]=> string(1) "5" ["patch"]=> string(2) "58" [3]=> string(2) "58" } Fatal error: Call to undefined function preg_last_error() in /in/d197u on line 35
Process exited with code 255.
Output for 5.0.0 - 5.0.1
<pre>int(1) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/d197u on line 11 RegEx extracted version partsPHP_EOLarray(7) { [0]=> string(6) "5.5.58" ["major"]=> string(1) "5" [1]=> string(1) "5" ["minor"]=> string(1) "5" [2]=> string(1) "5" ["patch"]=> string(2) "58" [3]=> string(2) "58" } Fatal error: Call to undefined function preg_last_error() in /in/d197u on line 35
Process exited with code 255.
Output for 4.4.5 - 4.4.9
<pre>int(1) RegEx extracted version parts array(7) { [0]=> string(6) "5.5.58" ["major"]=> string(1) "5" [1]=> string(1) "5" ["minor"]=> string(1) "5" [2]=> string(1) "5" ["patch"]=> string(2) "58" [3]=> string(2) "58" } Fatal error: Call to undefined function: array_combine() in /in/d197u on line 30
Process exited with code 255.
Output for 4.3.10 - 4.4.4
<pre>int(1) RegEx extracted version parts array(7) { [0]=> string(6) "5.5.58" ["major"]=> string(1) "5" [1]=> string(1) "5" ["minor"]=> string(1) "5" [2]=> string(1) "5" ["patch"]=> string(2) "58" [3]=> string(2) "58" } Fatal error: Call to undefined function: array_combine() in /in/d197u on line 30
Process exited with code 255.
Output for 4.3.3 - 4.3.9
<pre>int(1) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/d197u on line 11 RegEx extracted version partsPHP_EOLarray(7) { [0]=> string(6) "5.5.58" ["major"]=> string(1) "5" [1]=> string(1) "5" ["minor"]=> string(1) "5" [2]=> string(1) "5" ["patch"]=> string(2) "58" [3]=> string(2) "58" } Fatal error: Call to undefined function: array_combine() in /in/d197u on line 30
Process exited with code 255.
Output for 4.3.2
<pre>int(1) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/d197u on line 11 RegEx extracted version partsPHP_EOLarray(4) { [0]=> string(6) "5.5.58" [1]=> string(1) "5" [2]=> string(1) "5" [3]=> string(2) "58" } Fatal error: Call to undefined function: array_combine() in /in/d197u on line 30
Process exited with code 255.
Output for 4.3.0 - 4.3.1
<pre>int(1) Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/d197u on line 11 RegEx extracted version partsPHP_EOLarray(4) { [0]=> string(6) "5.5.58" [1]=> string(1) "5" [2]=> string(1) "5" [3]=> string(2) "58" } Fatal error: Call to undefined function: array_combine() in /in/d197u on line 30