이것은 루트 디렉토리에있는 index.php
본문에 있으며 localhost/sound/
에는 무작위로 명명 된 mp3
파일이 포함되어 있습니다.디렉토리에서 random mp3를 가져올 때 blank array_rand()
$files = glob("/sound/*.mp3");
if (count($files) < 1)
die('No files found');
$random = $files[array_rand($files)];
...
당신은 같은 일을 할 수 있지만, 제공 : 내가 브라우저에서 페이지의 소스를 볼 때
<?php
$files = glob("/sound/*.mp3");
$random = array_rand($files)
?>
<embed src="<?php echo $random ?>"
width="140" height="40" autostart="true" loop="TRUE">
</embed>
는
<embed src=""
width="140" height="40" autostart="true" loop="TRUE">
</embed>
사실, 업데이트 된 코드 –
아무것도 변경하지 않는 것, 나는 같은 디렉토리에있는 mp3를 사용하여 시도 PHP 파일 그래서 나는 'default.mp3'을 사용할 수 있습니다; 하지만 여전히 아무것도 나타나지 않고 열람 된 출처는 동일합니다 ... 무슨 일이 벌어지고 있습니까? O.o – John
'$ files'에'var_dump'를 실행합니다. 어떻게 보입니까? –