开发者

Showing a image created with the GC lib

开发者 https://www.devze.com 2023-01-02 11:55 出处:网络
i have my test.php: <?php echo \"Image:<br/>\"; include(\'draw.php\'); ?> and my draw.php: <?php

i have my test.php:

<?php

echo "Image:<br/>";

include('draw.php');

?>

and my draw.php:

<?php

$im开发者_如何学Gog = 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)?

?>


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>


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

0

精彩评论

暂无评论...
验证码 换一张
取 消