-2
<div id="leaderboardAd">
<?php
//THIS SCRIPT GENERATES A RANDOM AD.
$randomAd = rand(1,2);
switch($randonAd) {
case "1":
$adNumber = "/contributors.php";
$pngNumber = "/images/contributorsAd.png";
case "2":
$adNumber = "http://www.cameronmontesano.com";
$pngNumber = "/images/cameronmontesano-com.png";
default:
$adNumber = "/contributors.php";
$pngNumber = "/images/contributorsAd.png";
}
?>
<a href="<?php echo $adNumber ?>">
<img src="<?php echo $pngNumber ?>" width="720px" height="90px" />
</a>
</div>
它只顯示默認廣告。PHP隨機廣告不能用?
沒有php強制會處理該問題 – 2014-09-24 14:39:51
[PHP:switch](http://php.net/switch):*如果您沒有在案例的聲明列表末尾寫入break語句,PHP將繼續執行以下情況的陳述* – 2014-09-24 14:41:31