php 显示文件夹中的图像(幻灯片)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9484018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 06:55:23  来源:igfitidea点击:

Display Images From A Folder (slideshow)

phpimagedirectoryslideshow

提问by Remi

I have been trying to google and find out how to make a .php script that will make a an automatic slideshow of images from a folder, I've only managed to get the pictures to automatically show up on the php page, but I can't figure out how to make them slide one by one, like a slideshow.

我一直在尝试 google 并找出如何制作一个 .php 脚本,该脚本将从文件夹中自动显示图像幻灯片,我只设法让图片自动显示在 php 页面上,但我可以不知道如何让它们一张一张地滑动,就像幻灯片一样。

Hereis the url to the page where the images show up, so you can have a look Here is the code I've used.

是显示图像的页面的网址,因此您可以查看以下是我使用的代码。

<?
$files = glob("images/*.*");
for ($i=0; $i<count($files); $i++)
{
    $num = $files[$i];
    echo '<img src="'.$num.'" alt="random image" />'."<br><br>";
}
?>

Do you know how to make this happen? Or another way to do it? easier way? Java/XML?

你知道如何做到这一点吗?或者另一种方法来做到这一点?更简单的方法?Java/XML?

回答by Naftali aka Neal

To affect the client side, you'll need to use JavaScript. PHP only echos out static content on the server.

要影响客户端,您需要使用 JavaScript。PHP 只回显服务器上的静态内容。

Here is a list of options you coulduse

这是您可以使用的选项列表