title: How to get Screen Size in PHP with JavaScript with Conditions
body: <p>Trying to get Screen Size from JS in PHP working </p>
  
  <p>but if else conditions same value return </p>
  
  <p>Please Update Questions if you understand my questions </p>
  
  <p>i want to try this code not other </p>
  
  <pre><code>$screenwidth = "&lt;script&gt;
  
      var mobilewidth = console.log(screen.width); 
  
      if(mobilewidth &lt; '768'){
          document.write('Mobile');
      }else{
          document.write('Template');
      }   
  
  
  &lt;/script&gt;";
  echo $screenwidth;
  </code></pre>
  
  <blockquote>
    <p>Output = Template or Mobile in both conditions</p>
    
    <p>in PHP</p>
  </blockquote>
  
  <pre><code>function LoadTemplate() {
      $screenwidth = "&lt;script&gt;document.write(screen.width); &lt;/script&gt;";
  
  if($screenwidth&lt;=768){
      return 'Mobile';
  }else{
      return 'Template';
  }    
  }
  </code></pre>
  
  <blockquote>
    <p>Output = Template or Mobile both conditions</p>
  </blockquote>
  
  <p>How to fix this please help</p>