First prepare a few title pictures, 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:
- < img src= "/images/random/img_
PHP echo rand (1,6) ?>
- Border = "0" />
-
Is it easy to display images in PHP?
A little bit of a hassle with this approach is to rename the picture according to the rules above. If you don't want to rename the picture, you can also use the following method, but write a few 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 a picture on another website (Web 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 the PHP display image of the relevant implementation method, I hope to help you some.
http://www.bkjia.com/PHPjc/446078.html www.bkjia.com true http://www.bkjia.com/PHPjc/446078.html techarticle first prepare several title pictures, 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 ...