开发者

Block IE and Opera using PHP

I want to redirect user to a selected page if they use Any Version of IE or Opera. Because my website is using CSS 3 fully with different effects (animation effects) which are not supported by IE and Opera yet. I want to do it using PHP. Should the code bellow work?

if(preg_match('/MSIE/i',$u_agent) || pre开发者_如何学Gog_match('/Opera/i',$u_agent)) 
{ 
    header("Location: http://www.example.com/reject.html");
}

Or suggest me a better way please...


Use this

 if(preg_match('/MSIE|Opera/i',$u_agent))
 { 
      header("Location: http://www.example.com/reject.html");
 }


Unfortunately there is no way to do this only with PHP. Browsers usually send a user agent string, but this can be spoofed quite easily. There is no way to be 100% sure of the browser the user is using, however the most reliable way to tell is with JavaScript. You can either write your own or do a quick Google search and find a premade one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜