Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP

Name: Anonymous 2012-11-01 23:01

How do I use PHP to place an image into HTML?

$img = imagecreatefrompng("./dir/subdir/image.png");

Do I then do:

<img src="<?php "$img"; ?>" />

???

Name: Anonymous 2012-11-01 23:29


<?php
/* $img_path is your image's location; on most hosts, the contents of public_html would be your root directory and, for sanity, images would be stored in their own directory. */
 
$img_path = "http://www.yourdomain.com/images/img_000.png";

/* Then you generate the HTML and plop your PHP in */

?>

<!-- Make sure you use the .php extension on your filename and have PHP running -->
<img src="<?php echo $img_path; ?>" />

<!-- You can take this concept even further by abstracting everything so that you can reuse code.  But you'll find out about that as you go along -->

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List