Regular expression to detect Internet Explorer 11
问题 I am using this preg_match string preg_match('/Trident/7.0; rv:11.0/',$_SERVER["HTTP_USER_AGENT"] to detect IE11 so I can enable tablet mode for it. However it returns "unknown delimiter 7". How can I do this without PHP complaining at me? 回答1: Is this really a regular expression or just a literal string? If it's just a string, you can use the strpos function instead. if (strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false) { // your code } If it's a regular expression, you