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:
<img src="image_creator.php">
In the file "image_creator.php" I do following:
header ("Content-type: image/png");
$display_img=imagecreate(100, 50);
imagecolorallocate($display_img, 255, 255, 125);
imagepng($display_img);
imagedestroy($display_img);
This is a simplified version which works. I do something more about it which is not important for my question.
My question: 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?
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.