Can someone help me with a good example of using PHP to display a gif image?

Rob

New member
I've found a number of different examples online, all with different approaches. Can someone share a simple example of php code that will display a gif image on the page? I *think* that the server I'm running on is using PHP4

(I'm still in the learning stage and have a long way to go.)

Thanks
 
PHP just outputs HTML so all you have to do is this:

<?php

echo '<img src="example.gif'" alt="" />';

?>

Or if you need to show a gif as a stream of output from another script you could do this:


<?php
//example.php

header('Content-Type: image/gif');
readfile('images/example.gif');

?>

<html>
<body>
<img src="example.php" alt=""/>
</body>
</html>
 
Back
Top