我想將隨機swf變量回顯爲html,但我似乎無法得到正確的結果。如何在html中回顯變量(新手)
通過與螢火檢查我可以看到,它輸出我的PHP代碼的PHP回聲「$ randomImage」
我有什麼至今:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html>
<head>
<style media="screen" type="text/css">
.content {
position: absolute;
height: 200px;
width: 400px;
margin: -100px 0 0 -200px;
top: 25%;
left: 50%;
}
</style>
</head>
<body>
<?php
$imagesDir = '/';
$images = glob($imagesDir . '*.{swf}', GLOB_BRACE);
$randomImage = $images[array_rand($images)];
?>
<div class="content">
<center><object width="675" height="517"><param value="<?php echo '$randomImage' ?>" name="movie"><embed width="475" height="317" type="application/x-shockwave-flash" src="<?php echo '$randomImage' ?>"></object></center><center></center>
</div>
</body>
</html>
' '$ randomImage''應該只是$ randomImage或者用's – Class 2013-03-04 01:08:53
將你的單引號改爲雙引號 – 2013-03-04 01:09:21
如果你ar e看到整個語句'<?php echo'$ randomImage'; ?>在HTML輸出中,這意味着你的PHP代碼沒有被解析。這是從Web服務器運行嗎? (如果你只看到''$ randomImage',那麼它就是已經提到的引用。 – 2013-03-04 01:09:54