file4.phpとfile1.phpの2つのファイルを取得しました
INCLUDEを使用して、file4.phpが4回表示された場合、file1.phpが1回表示されて4:1の比率になるように配置するにはどうすればよいですか。ベストプラクティスは何ですか?
<?php
{
include("file4.php");
} else {
include("file1.php");
}
?>
file4.phpとfile1.phpの2つのファイルを取得しました
INCLUDEを使用して、file4.phpが4回表示された場合、file1.phpが1回表示されて4:1の比率になるように配置するにはどうすればよいですか。ベストプラクティスは何ですか?
<?php
{
include("file4.php");
} else {
include("file1.php");
}
?>
これにより、時間の経過とともにfile4が4対1の比率で含まれる2つのページの1つが表示されます。http://en.wikipedia.org/wiki/Law_of_large_numbers
$randInt = rand (1, 5);
if ($randInt > 1) include("file4.php");
else include("file1.php");
file4.php:
$GLOBALS['counter']++;
file1.php:
$GLOBALS['counter']++;
メインファイル:
if ($GLOBALS['counter'] % 5 == 0) {
include('file1.php');
} else {
include('file4.php');
}
しかし、それから座って、なぜあなたがこの種のものを必要とするのか疑問に思います。