$width = "<script>document.write(screen.width);</script>";
if($width >= 769) {
//desktop
}else
if{$width < 769) {
//mobile
}
$width = "<script>document.write(screen.width);</script>";
if("<script>document.write(screen.width);</script>" >= 769)
<?php if(!isset($_REQUEST['width'])){ ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=5.0, user-scalable=yes">
</head>
<body>
<script>
location.replace(location.protocol+'//'+location.host + location.pathname +'?width=' + document.body.offsetWidth);
</script>
</body>
</html>
<?php }else{
$width = intval($_REQUEST['width']);
?>
<!DOCTYPE html>
<html>
<head>
<title><?php echo $width >= 769 ? 'desktop' : 'mobile';?></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=5.0, user-scalable=yes">
<style>
html{}
body{
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
.desktop{color:green;}
.mobile{color:red;}
</style>
</head>
<body>
<h1 class="<?php echo $width >= 769 ? 'desktop' : 'mobile';?>">
<?php echo $width >= 769 ? 'desktop' : 'mobile';?>
</h1>
</body>
</html>
<?php }?>