Showing data routinely using PHP
I want to routinely do something using PHP.
For example, imagine that each 5 seconds I want to display something:
while(true) {
sleep(5);
echo "Test!";
}
But this won't work because it's an infinite loop.
So, what would be the correct way to do this?
This is only a simplification of what I want to do, I would like to extract data from a file every time it changes and insert it into a SQLite database, but und开发者_如何学Cerstanding how to do the previous example correctly would help me a lot. I don't know if there is a better way to do this instead of using PHP, so please tell me if I'm wrong.
What about using a cron job to call your script periodically? I understand it's the most common way to do it. The minimum granularity would be each minute, though...
Edit: Ignore my previous answer. I believe cron would be the easiest way to go about it.
If you're working on a windows server this will help: http://drupal.org/node/31506
精彩评论