IE (인터넷 익스플로러) 버전 알아내는 방법 - PHP 이용
최고관리자
|
댓글 0
PHP를 이용해 인터넷 익스플로러(IE)의 버전을 알아내는 방법입니다.
각 접속 버전에 따라 미리 준비해 둔 스타일을 적용하실 수 있습니다.
<?php
if ( preg_match('/msie [6]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie6.css" type="text/css" />'; //IE6
}elseif ( preg_match('/msie [7]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie7.css" type="text/css" />'; //IE7
}elseif ( preg_match('/msie [8]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie8.css" type="text/css" />'; //IE8
}elseif ( preg_match('/msie [9]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie8.css" type="text/css" />'; //IE9
}elseif ( preg_match('/msie [10]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie8.css" type="text/css" />'; //IE10
}
?>
각 접속 버전에 따라 미리 준비해 둔 스타일을 적용하실 수 있습니다.
<?php
if ( preg_match('/msie [6]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie6.css" type="text/css" />'; //IE6
}elseif ( preg_match('/msie [7]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie7.css" type="text/css" />'; //IE7
}elseif ( preg_match('/msie [8]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie8.css" type="text/css" />'; //IE8
}elseif ( preg_match('/msie [9]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie8.css" type="text/css" />'; //IE9
}elseif ( preg_match('/msie [10]/i',$_SERVER['HTTP_USER_AGENT']) ) {
echo '<link rel="stylesheet" href="css/ie8.css" type="text/css" />'; //IE10
}
?>
등록된 댓글이 없습니다.