3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $androidApp = 'ZooskAndroid'; $iphoneApp = 'ZooskiPhone'; $ipadApp = 'ZooskiPad'; $agent = 'ZooskAndroid/133 (Linux; U; Android 4.4.2; en-US; HTC One; Build/KOT49H.H1)'; $regExp = '/^(?:(?:' . $androidApp . ')|(?:' . $iphoneApp . ')|(?:' . $ipadApp . '))\/([0-9.]{1,6}),/'; preg_match_all($regExp, $ua, $matches); if (is_array($matches) && count($matches) === 2) { $version = $matches[1]; } if (empty($version)) { // ZooskAndroid/133 (Linux; U; Android 4.4.2; en-US; HTC One; Build/KOT49H.H1) $regExp = '/^(?:(?:' . $androidApp . '))\/([0-9.]{1,6}) \(/'; preg_match_all($regExp, $ua, $matches); $version = $matches[1]; } if (is_array($version) && count($version) === 1) { $version = is_array(current($version)) ? null : current($version); } else { $version = null; } echo $version;
Output for 5.0.4 - 5.6.28, hhvm-3.10.0, 7.0.0 - 7.1.0
Notice: Undefined variable: ua in /in/2Fbnl on line 10 Notice: Undefined variable: ua in /in/2Fbnl on line 19
Output for hhvm-3.12.0
Notice: Undefined variable: ua in /in/2Fbnl on line 10 Warning: preg_match_all() expects parameter 2 to be string, null given in /in/2Fbnl on line 10 Notice: Undefined variable: ua in /in/2Fbnl on line 19 Warning: preg_match_all() expects parameter 2 to be string, null given in /in/2Fbnl on line 19
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: ua in /in/2Fbnl on line 10 Notice: Undefined variable: ua in /in/2Fbnl on line 19