Gunnar J Posted April 12, 2008 Share Posted April 12, 2008 Ive searched on google a lot, but I just cant find how to display images with PHP, iis all "Image Manipulation" and "Image Gallerys" etc.So I am asking, how do I display images?!? Link to comment Share on other sites More sharing options...
boen_robot Posted April 12, 2008 Share Posted April 12, 2008 You don't. PHP just generates HTML. It can also do many other things "in the meantime" like manipulating images that you'll display later, but that's not like "displaying an image with PHP" as if it's an alternative to HTML of some sort. You can send a complete image instead of an HTML file, but not put it inline with the rest. Link to comment Share on other sites More sharing options...
jeffman Posted April 12, 2008 Share Posted April 12, 2008 Okay. I assume you don't need this first part, but here it is anyway. <img src="<?php $img = 'myimage.png'; echo $img; ?>" /> Now, with additions and modifications, the above can be used to grab a random image or even manipulate an image, so you can take it pretty far.But let's say you want a fixed HTML file that has a tag in it like <img src="myserver.com/img.php" /> .img.php would be a script that goes out and gets images for you for whatever purpose you have in mind. In its most basic form, it'll look like this, using the GD extensions to php: <?php $im = imagecreatefrompng($imgpath_or_URL); header("Content-Type: image/png"); imagepng($im);?> Hope some of that helps. Link to comment Share on other sites More sharing options...
Gunnar J Posted April 12, 2008 Author Share Posted April 12, 2008 Well, I have an If sunction and want to display an image if you selected two things, but I cant seem to do it... Ill try your's Dierdes Dad Link to comment Share on other sites More sharing options...
jeffman Posted April 12, 2008 Share Posted April 12, 2008 FWIW, this topic should never have been reposted into another thread. No real harm done today, but on a busy day, things might have gotten confusing. Please trust that we are paying attention. Link to comment Share on other sites More sharing options...
Synook Posted April 13, 2008 Share Posted April 13, 2008 Well, I have an If sunction and want to display an image if you selected two things, but I cant seem to do it... Ill try your's Dierdes DadIf you have a specific problem, specific code helps us to understand it Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.