The image cannot be displayed because it contains errors

You must not output anything before header(). Just start your document with <?php (as the first file characters), followed by the code for displaying the image. Skip the HTML tags. Do not even write a single blankline before header().

If you want to display an image inside the html document of yours, you must do it in two files. One, call it for example image.php, containing only the PHP code including the header. The second file, call it show.php or show.html, includes the HTML code you like, including <img src="https://stackoverflow.com/questions/3385982/image.php" alt="Your generated image" />.

Leave a Comment