I found this topic: convert text to image in php
and I tested the code that Sourabh Shankar provide.
When I paste this code in a new empty php file and I adjust the font path, then it works perfect!
But when I put a echo before or after the header('Content-type: image/png'); line, then it all fails
Can someone provide me a code of how to call this image creator in a HTML file:
<span>Here comes the image</span>
<?php [call function??] ?>
<span>and here we continue with some HTML</span>
The PHP code you linked to works as a stand-alone file, so that when it is requested in a browser it will send back an image. Setting the header with
means that the code will return content which the browser interprets as an image file, rather than a HTML file.
You couldn't use PHP to directly output a file into HTML. You would need to use that code in a separate file and link it to the src tag of an image in your code.