0

file4.phpとfile1.phpの2つのファイルを取得しました

INCLUDEを使用して、file4.phpが4回表示された場合、file1.phpが1回表示されて4:1の比率になるように配置するにはどうすればよいですか。ベストプラクティスは何ですか?

<?php 
  {
    include("file4.php");

} else {

    include("file1.php");
  }
?>
4

2 に答える 2

7

これにより、時間の経過とともに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");
于 2012-04-16T21:17:34.980 に答える
-2

file4.php:

$GLOBALS['counter']++;

file1.php:

$GLOBALS['counter']++;

メインファイル:

if ($GLOBALS['counter'] % 5 == 0) {
    include('file1.php');
} else {
    include('file4.php');
}

しかし、それから座って、なぜあなたがこの種のものを必要とするのか疑問に思います。

于 2012-04-16T21:18:50.083 に答える