title: How to assign a php function instead of a separate php file in img src
body: <p>I have found following way of creating a sample image via php in a separate php file which then is included in the img src attribute:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;img src="image_creator.php"&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>In the file "image_creator.php" I do following:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>header ("Content-type: image/png");
  $display_img=imagecreate(100, 50);
  imagecolorallocate($display_img, 255, 255, 125);
  imagepng($display_img);
  imagedestroy($display_img);</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is a simplified version which works. I do something more about it which is not important for my question.</p>
  
  <p><strong>My question:</strong> how is it possible to include above php code from the separate file "image_creater.php" directly in the leading php file including the HTML img statement?</p>
  
  <p>I tried to use the php code inside a php function and put that function inside the img src attribute but it did not work. The background of my question is that I additionally use a text code to be printed inside the image and I don't want to disclose this text code via "image_creator.php?code=xxx" which would be visible in the HTML code of the img of course.</p>