title: Image rotation in PHP with link based on device display size
body: <p>I am looking for image rotation based on device. Example if website load on desktop it should load desktop.png and if same website load in mobile it should load mobile.png</p>
  <p>My JS code :</p>
  <pre><code>&lt;script type=&quot;text/javascript&quot;&gt;
      if (screen.width &lt;= 720) {
       document.write('&lt;a href=&quot;http://example.com/mobile&quot;&gt;&lt;img src=&quot;mobile.png&quot;&gt;&lt;/a&gt;');
      } else {
       document.write('&lt;a href=&quot;http://example.com/desktop&quot;&gt;&lt;img src=&quot;desktop.png&quot;&gt;&lt;/a&gt;');
      }
  &lt;/script&gt;
  </code></pre>
  <p>I have rewrite the JS code to PHP Code :</p>
  <pre><code>if (get($screen, &quot;width&quot;) &lt;= 720.0) {
    echo &quot;&lt;a href=\&quot;http://example.com/mobile\&quot;&gt;&lt;img src=\&quot;mobile.png\&quot;&gt;&lt;/a&gt;&quot;;
  } else {
    echo &quot;&lt;a href=\&quot;http://example.com/desktop\&quot;&gt;&lt;img src=\&quot;desktop.png\&quot;&gt;&lt;/a&gt;&quot;;
  }
  </code></pre>
  <p>The above JavaScript code is working fine but my PHP code is giving a error. Can anyone please help to fix it?</p>