更改.txt时自动刷新页面

时间:2020-03-14 13:23:29

标签: php html page-refresh file-read

所以我一直试图在php请求中制作一个播放YouTube链接的页面

我用过php,并且用过

<?php
$VID = $_GET['vid'];
echo $VID;
$file = fopen("Vid.txt","w");
fwrite($file,$VID);
?>

发出$ _get请求以获取YouTube ID并将其写入.txt文件

然后我做了一个页面来读取文件,并在嵌入的YouTube链接上使用它


<?php
$file = fopen ("Vid.txt","r");
$id = fread($file,filesize("Vid.txt"));
fclose($file);
echo $id;
echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/' . $id  . '?autoplay=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
?>

我想知道的是当.txt更改时如何自动重新加载页面

P.S:我对php,html和javascript非常了解

预先感谢

0 个答案:

没有答案
相关问题