0
FIXED!
Feel free to use my code, no need to cite my work. There was no problem, just that the image size was too small and some weren't showing up. duh.

I will change the size from 100px to 500px for anyone who wants to use this code.

Have fun

インターネットで入手できるオープンコードを使用して、ランダムフラッシュジェネレーターを作成しようとしています。

元のコード:

<?php
$imglist='';
//$img_folder is the variable that holds the path to the swf files.
// see that you dont forget about the "/" at the end
$img_folder = "images/";
mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, ad them to a list
while ($file = $imgs->read()) {
if (eregi("swf", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];
//display random swf
echo '<embed src="'.$img_folder.$image.'" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="100"
height="100"></embed>';
?>

私の変更されたコード:

<?php
$imglist='';
//$img_folder is the variable that holds the path to the swf files.
// see that you dont forget about the "/" at the end
$img_folder = "../files/flash/";
mt_srand((double)microtime()*1000);
//use the directory class
$imgs = dir($img_folder);
//read all files from the directory, ad them to a list
while ($file = $imgs->read()) {
if (preg_match("/(swf)/i", $file))
$imglist .= "$file ";
} closedir($imgs->handle);
//put all images into an array
$imglist = explode(" ", $imglist);
$no = sizeof($imglist)-2;
//generate a random number between 0 and the number of images
$random = mt_rand(0, $no);
$image = $imglist[$random];
//display random swf
echo '<embed src="'.$img_folder.$image.'" quality="high"
pluginspage="http://www.macromedia.com/go/getflashplayer"
type="application/x-shockwave-flash" width="500"
height="500"></embed>';
?>

私は最初、11 行目の ergi に問題がありました。それを preg に置き換えるように言われました。

ランダム ページ ( http://www.nsgaming.us/random/ )をロードすると、フォルダーにあったランダム フラッシュ オブジェクトがほんの一瞬点滅しましたが、今は何も表示されません。

助けてください?

私のインデックスは次のように表示されます:

    <html>
    <head>
        <title>test</title>
        <?php 
    include("../menu.php");
    include_once('random2.php');
    ?>
    </head>
    <body>
<p>This is the random page.</p>
<p>I am planning on having random flash objects load here but still working on it.</p>
</body>
</html>

私は Web デザイン、HTML、および PHP のモデレートを行うのが初めてであることを覚えておいてください。あなたが何か愚かなことをしたことで私に怒鳴らないように努めることができれば、それはおそらく起こったことです.

4

2 に答える 2

1

フラッシュ オブジェクトは 404 を返しています。

それらの1つは実際に機能します。

http://www.nsgaming.us/files/flash/anon_partyhard007.swf

これに基づいて、間違ったファイルフォルダーを見ている可能性があると思います。パブリック ファイル フォルダーがあり、ルートの 1 レベル下にファイル フォルダーがあると思いますか?

ひょっとしたらこちらの方がうまくいくかもしれません。

$img_folder = "./files/flash/";
于 2013-07-30T17:30:31.523 に答える