Rotación por hora de un archivo PHP incluido

How can I rotate a PHP included file on an hourly rotation schedule?

I have a index.php and four files with some content. I want, for every six hours, a different content-file will be included.

For example, in the first time period:

<?php include 1.php ?>

Some hours later:

<?php include 2.php ?>

Again, some hours later:

<?php include 3.php ?>

I already tried Googling and made something like this:

<?php
// starting date for rotation
$startDate = '2013-09-10';
// array of filenames
$files = array('1.php','2.php','3.php','4.php');

$stamp = strtotime($startDate);
$days = (time() - $stamp) / (0*0*6);
$filesName = $files[$days % count($files)]
?>

<?php include $filesName; ?>

Sin embargo, esto no funciona.

¿Cómo puedo arreglar esto?

preguntado el 10 de septiembre de 13 a las 00:09

Nice that you included what you actually had tried. It would also be helpful for your question if you included the result/error message instead of simply saying esto no funciona -

1 Respuestas

qué tal si:

<?php
$hour=date('G',time());
if($hour ==0) $hour = 1; //take care of hour 0
$file=ceil($hour/6);


include $file.'.php';
?>

Respondido el 10 de Septiembre de 13 a las 01:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.