定期自动发送变量到 PHP 页面
每 4 秒我刷新一个 php 页面并更新时间。 每次发生这种情况时,我都想将时间发送到另一个页面,但不离开该页面 这令人耳目一新...
下面是一些示例代码:
<?
$target = mktime(10, 0, 0, 0, 0, 0) ;
header('refresh:4; url=timer.php');
$today = (int)(time ());
$siteToReceiveTime = "http://www.nbit.co.za/toriggo/receive.php?time=$today";
print "time in $today seconds";
?>
Every 4 seconds I am refreshing a php page and it updates the time.
Each time this happens I want to send the time to another page but NOT navigate away from the page
that is refreshing the time...
Below is some sample code:
<?
$target = mktime(10, 0, 0, 0, 0, 0) ;
header('refresh:4; url=timer.php');
$today = (int)(time ());
$siteToReceiveTime = "http://www.nbit.co.za/toriggo/receive.php?time=$today";
print "time in $today seconds";
?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有几种方法可以做到这一点......
Ajax 就是其中之一 - 它可以处理每 4 秒的位,并且能够在不更改页面的情况下发出请求。
另一种选择是使用 php curl...
There are a couple of ways that you could do this...
Ajax being one - that could handle the every 4 seconds bit and would be able to make requests without changing the page.
The other option would be with php curl...
阅读 CURL 函数文档。您可以让 PHP 调用 CURL 从 PHP 脚本加载页面,而不会干扰您的用户。
Read the CURL function documentation. You can have PHP call CURL to load the page for you from the PHP script without interfering with your users.