3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $oses = array( 'Windows 95' => array('win95', 'windows 95'), 'Windows 98' => array('win98', 'windows 98'), 'Windows CE' => 'windows ce', 'Windows ME' => array('windows 9x 4.90', 'windows me'), 'Windows NT' => array('winnt4.0', 'windows nt 4.0'), 'Windows 2000' => array('winnt5.0', 'windows nt 5.0'), 'Windows XP' => array('winnt5.1', 'windows nt 5.1'), 'Windows 2003 Server' => 'windows nt 5.2', 'Windows Vista' => 'windows nt 6.0', 'Windows 7' => 'windows nt 6.1', 'Windows 8' => 'windows nt 6.2', 'Windows Unatended' => 'windows', 'iOS' => array('iphone', 'ipad', 'ipod'), 'Mac OS X 10.0' => 'mac os x 10.0', 'Mac OS X 10.1' => 'mac os x 10.1', 'Mac OS X 10.2' => 'mac os x 10.2', 'Mac OS X 10.3' => 'mac os x 10.3', 'Mac OS X 10.4' => 'mac os x 10.4', 'Mac OS X 10.5' => 'mac os x 10.5', 'Mac OS X 10.6' => 'mac os x 10.6', 'Mac OS X 10.7' => 'mac os x 10.7', 'Mac OS X 10.8' => 'mac os x 10.8', 'Mac OS X 10.9' => 'mac os x 10.9', 'Mac OS X' => 'mac os x', 'Macintosh' => array('powerpc', 'macintosh'), 'Android 5.x' => 'android 5', 'Android 4.x' => 'android 4', 'Android 3.x' => 'android 3', 'Android 2.x' => 'android 2', 'Android 1.x' => 'android 1', 'Android' => 'android', 'Linux' => 'linux', 'Free BSD' => 'freebsd', 'Net BSD' => 'netbsd', 'Open BSD' => 'openbsd', 'Sun OS' => 'sunos', 'Symbian' => 'symbian', 'Tapatalk' => 'tapatalk', ); #$useragent = strtolower('Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3'); $useragent = strtolower('Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7 (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)'); #$useragent = strtolower('Mozilla/4.0 (compatible; MSIE 4.0; Windows 95; .NET CLR 1.1.4322; .NET CLR 2.0.50727'); foreach ($oses as $os => $identificator) { if (is_array($identificator)) { #user_error($useragent, E_USER_NOTICE); foreach ($identificator as $ident) { user_error($ident, E_USER_NOTICE); if (preg_match("#$ident#i", $useragent)) { user_error('FOUND!', E_USER_NOTICE); $browser['os'] = $os; break 2; } } } else { user_error($identificator, E_USER_NOTICE); if (preg_match("#$identificator#i", $useragent)) { $browser['os'] = $os; break; } } } user_error($browser['os'], E_USER_NOTICE); ?>
Output for 4.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: win95 in /in/c6mKK on line 54 Notice: windows 95 in /in/c6mKK on line 54 Notice: win98 in /in/c6mKK on line 54 Notice: windows 98 in /in/c6mKK on line 54 Notice: windows ce in /in/c6mKK on line 65 Notice: windows 9x 4.90 in /in/c6mKK on line 54 Notice: windows me in /in/c6mKK on line 54 Notice: winnt4.0 in /in/c6mKK on line 54 Notice: windows nt 4.0 in /in/c6mKK on line 54 Notice: winnt5.0 in /in/c6mKK on line 54 Notice: windows nt 5.0 in /in/c6mKK on line 54 Notice: winnt5.1 in /in/c6mKK on line 54 Notice: windows nt 5.1 in /in/c6mKK on line 54 Notice: windows nt 5.2 in /in/c6mKK on line 65 Notice: windows nt 6.0 in /in/c6mKK on line 65 Notice: windows nt 6.1 in /in/c6mKK on line 65 Notice: windows nt 6.2 in /in/c6mKK on line 65 Notice: windows in /in/c6mKK on line 65 Notice: iphone in /in/c6mKK on line 54 Notice: FOUND! in /in/c6mKK on line 57 Notice: iOS in /in/c6mKK on line 74
Output for hhvm-3.10.0 - 3.12.0
Notice: win95 in /in/c6mKK on line 54 Notice: windows 95 in /in/c6mKK on line 54 Notice: win98 in /in/c6mKK on line 54 Notice: windows 98 in /in/c6mKK on line 54 Notice: windows ce in /in/c6mKK on line 65 Notice: windows 9x 4.90 in /in/c6mKK on line 54 Notice: windows me in /in/c6mKK on line 54 Notice: winnt4.0 in /in/c6mKK on line 54 Notice: windows nt 4.0 in /in/c6mKK on line 54 Notice: winnt5.0 in /in/c6mKK on line 54 Notice: windows nt 5.0 in /in/c6mKK on line 54 Notice: winnt5.1 in /in/c6mKK on line 54 Notice: windows nt 5.1 in /in/c6mKK on line 54 Notice: windows nt 5.2 in /in/c6mKK on line 65 Notice: windows nt 6.0 in /in/c6mKK on line 65 Notice: windows nt 6.1 in /in/c6mKK on line 65