I need to find the screen resolution of a users screen who visits my website?
I found using CSS inside my html inside my php did the trick for me.
<?php             
    echo '<h2 media="screen and (max-width: 480px)">'; 
    echo 'My headline';
    echo '</h2>'; 
    echo '<h1 media="screen and (min-width: 481px)">'; 
    echo 'My headline';
    echo '</h1>'; 
    ?>
This will output a smaller sized headline if the screen is 480px or less. So no need to pass any vars using JS or similar.
You can check it like below:
if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'android')) {
   echo "mobile web browser!";
} else {
echo "web browser!";
}
                                                                        <script type="text/javascript">
if(screen.width <= 699){
    <?php $screen = 'mobile';?>
}else{
    <?php $screen = 'default';?>
}
</script>
<?php echo $screen; ?>