tags:

views:

12

answers:

2

i have my test.php:

<?php

echo "Image:<br/>";

include('draw.php');

?>

and my draw.php:

<?php

$img = imagecreate(250,80);

...

header("Content-type: image/jpeg"); imagejpeg($img); imagedestroy($img);

?>

now, visiting test.php tells me that headers is already sent. How do i show the image in draw.php "realtime" (not by saving to server and loading it using img tag)?

?>

A: 

Remove echo "Image:<br/>"; from test.php and read carefully about HTTP headers http://php.net/manual/en/function.header.php so that you don't make the same mistake again

bogdanvursu
Well that works because it will be the same as going directly to the draw.php. BUT i want to show the image with other content, like "Image: <br />"
Jason94
Seems I misunderstood what you wanted to achieve.
bogdanvursu
+1  A: 

If you want to incorporate this into an html page, change test.php to this:

<?php
    echo "Image:<br/>";
    echo '<img src="draw.php" />'
?>

You could just as easily make it a static html page:

<html>
  <head>
   <title>Test</title>
  </head>
  <body>
    Images: <br />
    <img src="draw.php" />
  </body>
</html>
fmark
Just what i wanted!
Jason94