lib.php:
<?php
function get_time() {
loop = true;
while (loop) {
echo date("F j, Y, g:i a");
}
}
?>
index.php contains this:
<?php
include("lib.php");
?>
and this somewhere further down:
<?php
get_time();
?>
However, I don’t see anything.
So I see two potential problems here. Either I need to declare the include() at the same time as I declare the function. Or PHP is unable to display continuous data (like in the case of this while loop) on a webpage without refreshing.
If it’s the former, is there a way to declare the include() globally for my whole page? If it’s the latter, how can I get it to show the contents of a continuous loop on my page? Will I have to use another language? Thanks
This piece of code will loop infinitely:
So the fact that you do not see anything is probably because of this.
Also, you are correct – to see continuously updated data like this, you either need to be refreshing the page, or update the content through AJAX calls.