注册 | 登陆

随机图片代码

CGI的


Code:

[Ctrl+A Select All]

PHP的


Code:

[Ctrl+A Select All]

getRandomImage()
This function will take a random image from a directory and display it in your webpage. It can be modified to do many other things and list various other file types besides just images. All this does is print a random file name from your directory, you can do whatever you like with it.
这个感觉最好,我翻译下:
这个功能可以从某目录里读出随机图片显示到你页面里,它可以被修改成很多其他东西,除了图片外也可以列出各种类型的文件。所有这些所做的就是从你的一个目录打印出一个随机文件名,可以用他来做你想要的任何事情:)



Code:

[Ctrl+A Select All]



Essentially choosing a random image with PHP is pretty easy. In the above snippet of code, eregi looks for images ending with gif,jpg,jpeg or png ... don't hesitate to add others. It's also good to call srand() only once per script call, so if you have multiple random images per page, adjust the function (maybe this should be taken into account).
实际上用PHP选择一个随机图片很简单,在上面代码里,可以寻找gif,jpg,jpeg or png 结尾的图片。还可以加其他的后缀:)

Of course it doesn't write HTML, that's your job. Here's an example:
当然,它不写HTML,那是你自己的事情,这里是例子


Code:

[Ctrl+A Select All]
刷一次变一次图的ASP代码




Code:

[Ctrl+A Select All]

« 上一篇 | 下一篇 »

Trackbacks

点击获得Trackback地址,Encode: UTF-8

发表评论

评论内容 (必填):