You can't save a javascript value into a php variable directly. But you can....Put the php value into a javascript variable and use that for making your changes using javascript.
<?php  echo '<script type="text/javascript">var jVar = "$phpVar";'; ?>
If you are importing your script from a js file you will want to add this before your import or course.
And I'm not sure what you're trying to accomplish but if you need a js value you can always send that value using an ajax Request...
var ajax = new XMLHttpRequest();
var form  = new FormData();
form.append('win_size',window.innerWidth);
ajax.open("http://example.com/processJSWindowSize.php","POST",true);
ajax.send(form);
On the server side code, which in this example is processJSWindowSize.php, you can have something along the lines of
<?php 
    if($_SERVER['REQUEST_METHOD'] == 'POST'){ 
        $jsWindowSize = strip_tags(stripslashes($_POST['win_size']));
        //do what you need with the window size
    } 
?>