php - Detect client using site in mobile -
this question has answer here:
- is there css media query detect windows? 4 answers
can detect client's operating system using php, mobile, android or windows display site's design responsive.
i have used,
css
@media screen , (min-width: 1200px) {      /*          detected pc.      */ } @media screen , (min-width: 500px) {      /*          detected mobile or pc.      */ } but don't want write both css in same page , wanted load them php
php
<?php     $is_pc = ???; //don't know write.     if ($is_pc) {        echo '<link href="pc.css" rel="stylesheet">';     } else {        echo '<link href="mobile.css" rel="stylesheet">';     } ?> 
bad practice , main, far one, :
if choose witch css load server side, you'll not able handle switch on tablet between vertical , horizontal mode (hz = desktop view; vt = mobile one), you'll not have reload of page.
this why should load both media query in css @ same time.
if want make same behaviour, use :
<link rel="stylesheet" media="screen , (max-width: 768px)" href="mobile.css" /> <link rel="stylesheet" media="screen , (min-width: 768px)" href="pc.css" />  
Comments
Post a Comment