ページにアクセスするごとに、
ランダムに選択されたアフィリエイトのバナーを表示するスクリプト。
「banner.php」を以下の内容でルートに作成。
(例:http://www.example.com/banner.php)
<?php
$bnSrc[0]='<a href="http://www.example.com/" target="_blank"><img src="http://www.example.com/banner1.jpg" alt="バナー1" border="0" /></a>';
$bnSrc[1]='<a href="http://www.example.com/" target="_blank"><img src="http://www.example.com/banner2.jpg" alt="バナー2" border="0" /></a>';
$bnSrc[2]='上記同様にバナーのタグを入れる';
$n = mt_rand(0,count($bnSrc)-1);
$bn = $bnSrc[$n];
echo $bn;
?>
PHPファイルのバナーを表示したい箇所に以下のコードを記述。
(例えば、http://www.example.com/index.phpの場合)
<?php
$openfile = file_get_contents('http://www.example.com/banner.php');//
echo $openfile;//
?>
こでだけでOK。
Javascriptで同じことをする方法は以下を参照

