title: How to put a PhP variable inside an img src?
body: <p>I'm trying to put an image in my website, but I need the <strong>src</strong> to be a <strong>php variable</strong>, and I get the console error that "Path couldn't be found", but the Image should be there.</p>
  
  <p>Setting image variable</p>
  
  <pre><code>&lt;?php
      $rand = rand(1,2);
      $image = "imagePath";
  
      switch ($rand) {
          case 1:
              $image = "images/image1.jpg";
              break;
          case 2:
              $image = "images/image2.png";
              break;
          default:
              break;
      }
  ?&gt;
  </code></pre>
  
  <p>Trying to retrieve it</p>
  
  <pre><code>&lt;img src="&lt;?php $image ?&gt;" /&gt;
  </code></pre>
  
  <p>Error message</p>
  
  <blockquote>
    <p><em>file:///C:/Users/Leonardo/Desktop/Games/M/Site/%3C?php%20$image%20?%3E</em>
    Failed to load resource: net::ERR_FILE_NOT_FOUND</p>
  </blockquote>
  
  <p>How to insert the <code>$image</code> path inside a <strong>src</strong> attribute in an <strong>img</strong>?</p>