PDA

View Full Version : Image holder in php



agibbis
08-19-2008, 10:25 PM
Hi there

I am after the image link, but written for use in php.
e.g. the HTML link:
<img src="/testpic.jpg" width="350" height="350">

But to be able to work in a php file and display an image on the page calling it.


I hope this won’t mean anything to lengthy but any help would be most appreciated

jackbenimble4
08-24-2008, 07:17 PM
I think you might have several concepts confused here.

A php file is interpreted, and often turned into HTML. PHP is not a content type. You can't "display an image in a php file." You can however program it to display an image in a certain medium. In this case, it looks like you want to display it in html. Here are some related examples that should help you:



<?php

// This is a php script...

// let's revert to basic html to display the image
?>
<img src="/testpic.jpg" width="350" height="350" />
<?php

// Finish whatever we need to do

?>


Or...



<?php

// This is our php script...

// Print that image...

echo "<img src=\"/testpic.jpg\" width=\"350\" height=\"350\" />";

// Finish whatever we need to do
?>


Or...



<?php

$filename = "/testpic.jpg";
$width = 350;
$height = 350;

// print that image
echo "<img src=\"" . $filename . "\" width=\"" . $width . "\" height=\"" . $height . "\" />";

?>