I'm working on generating output on a section of a page at regular intervals with php and javascript. I'm brand new to js, so please forgive any obtuse questions.
The original php code is;
<?php
$data = file_get_contents("http://" . $phoneControlUsername .":" . $phoneControlPassword . "@" . $ip . "/CGI/Screenshot");
$filename = "tempFiles/phoneScreenshot$dev";
file_put_contents($filename, $data);
echo "<img src=" . $filename . " style='width:100%;'>"
?>
This used to be part of my main page, but I moved it over to its own file called screenGen.php. My main page can call on it with no problem at all;
require('screenGen.php');
I need this particular code to be generated every five seconds. So, in reading how javascript and php can be used together, I came up with;
<script>
window.setInterval(function()
{
screenGen = '<?php require('screenGen.php'); ?>';
document.write(screenGen);
}, 5000);
</script>
Of course, this does not work. I can't find the right directions on how to do something like this because, being new to the subject, I don't know how to look for it. How can I generate screenGen.php at regular intervals?