php幻灯片演示示例

php幻灯片演示示例,php,slideshow,Php,Slideshow,我尝试用php做一个简单的图像幻灯片(只循环图像,没有链接,没有其他效果) 通过谷歌搜索,我在网上发现了以下内容: <HTML> <HEAD> <TITLE>Php Slideshow</TITLE> <script language="javascript"> var speed = 4000; // time picture is displayed var delay = 3; // time it takes to blend

我尝试用php做一个简单的图像幻灯片(只循环图像,没有链接,没有其他效果)

通过谷歌搜索,我在网上发现了以下内容:

<HTML>
<HEAD>
<TITLE>Php Slideshow</TITLE>
<script language="javascript">
var speed = 4000; // time picture is displayed
var delay = 3; // time it takes to blend to the next picture
x = new Array;
var y = 0;

<?php
$tel=0;
$tst='.jpg';
$p= "./images";
$d = dir($p);
$first = NULL;
while (false !== ($entry = $d->read())) {
    if (stristr ($entry, $tst)) {
        $entry = $d->path."/".$entry; 
        print ("x[$tel]='$entry';\n");
        if ($first == NULL) { 
            $first = $entry; 
        }
        $tel++;
    }
}
$d->close();
?>

function show() {
    document.all.pic.filters.blendTrans.Apply();
    document.all.pic.src = x[y++];
    document.all.pic.filters.blendTrans.Play(delay);
    if (y > x.length - 1) 
        y = 0;
}

function timeF() {
  setTimeout(show, speed);
}
</script>
</HEAD>
<BODY >

<!-- add html code here -->
<?php
print ("<IMG src='$first' id='pic' onload='timeF()' style='filter:blendTrans()' >");
?>
<!-- add html code here -->
</BODY>
</HTML>

Php幻灯片
var速度=4000;//显示时间图片
var延迟=3;//混合到下一张图片所需的时间
x=新阵列;
var y=0;

我建议您使用现成的javascript框架,例如


我记得,我用过这个:

我正在开发一个基于jquery的幻灯片放映插件。随着幻灯片放映的进行,您可以向幻灯片放映添加更多图像。。它是测试版


您能给我看一个样品吗?有点困惑,不知道从哪里开始。
<HTML>
<HEAD>
<TITLE>Php Slideshow</TITLE>
<script language="javascript">
var speed = 4000; // time picture is displayed
var delay = 3; // time it takes to blend to the next picture
x = new Array;
var y = 0;

x[0]='./images/under_construction.jpg';
x[1]='./images/BuildingBanner.jpg';
x[2]='./images/littleLift.jpg';
x[3]='./images/msfp_smbus1_01.jpg';
x[4]='./images/escalator.jpg';

function show() {
    document.all.pic.filters.blendTrans.Apply();
    document.all.pic.src = x[y++];
    document.all.pic.filters.blendTrans.Play(delay);
    if (y > x.length - 1) 
        y = 0;
}

function timeF() {
  setTimeout(show, speed);
}
</script>
</HEAD>
<BODY >

<!-- add html code here -->
<IMG src='./images/under_construction.jpg' id='pic' onload='timeF()' style='filter:blendTrans()' ><!-- add html code here -->
</BODY>
</HTML>