Experience Sharing PHP display pictures. First, prepare several titles and name them img_1.jpg, img_2.jpg, img_3.jpg, img_4.jpg, img_5.jpg, and img_6.jpg. Of course, you can also use other types of images, such as gif. However
First, prepare several title images and name them:
Img_1.jpg, img_2.jpg, img_3.jpg, img_4.jpg, img_5.jpg, img_6.jpg.
Of course, you can also use other types of images, such as gif. Then, upload these images to a folder, for example, "/images/random ".
Next, use the following PHP to display the image code:
-
- . Jpg "border =" 0 "/>
-
Is it easy to display pictures in PHP?
This method is a little troublesome because you need to rename the image according to the above rules. If you do not want to rename the image, you can use the following method, but you need to write several more lines of PHP code. :-)
- < ?php
- $dir = $_SERVER['DOCUMENT_ROOT']
. "images/random";
- chdir ($dir);
- $images = glob("*.{gif,png,jpg}
", GLOB_BRACE);
- $file = $images[array_rand($images)];
- ?>
- < img src="< ?php echo ("/
images/random/$file"); ?>"
border="0" />
Call images from other websites (online album)
- < ?
- $id=rand(1,5);
- $image[1]='http://farm.static.flickr.com/1.png';
- $image[2]='http://farm.static.flickr.com/2.png';
- $image[3]='http://farm.static.flickr.com/3.png';
- $image[4]='http://farm.static.flickr.com/4.png';
- $image[5]='http://farm.static.flickr.com/5.png';
- header("location:$image[$id]");
- ?>
The above code example is related to the implementation of PHP image display. I hope it will be helpful to you.
Img_1.jpg, img_2.jpg, img_3.jpg, img_4.jpg, img_5.jpg, img_6.jpg. Of course, you can also use other types of images, such as gif. However...