- preg_match: documentation ( source)
<?php
if(preg_match('/MSIE (.*?);/',
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
)
||
preg_match('/^(?=.*(Trident))(?=.*(rv:11.0)).*$/',
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)"
))
{
$url = 'IE detected';
} else {
$url = 'not detected';
}
echo $url;