简体   繁体   English

如何在不实际打开 php 文件的情况下在后台运行 php 文件? (基于时间的事件)

[英]How to run a php file in the background without actually opening the php file? (Time based event)

<?php

session_start();

$con = mysqli_connect('localhost', 'root');

mysqli_select_db($con, 'id12887901_visitor');

$query = "select * from curvis1 order by id desc limit 1";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);

date_default_timezone_set('Asia/Hong_Kong');
$today = date("H:i:s");
  echo $today;  

if ($today == $row['end_at']){
  $msg = "Visitor No.1 pass has expired.";
  $reg = "insert into msg(comment) values('$msg')";
  mysqli_query($con, $reg);
  echo "WTF";

} else  {
  echo "LOL";

}


?>

I want it to run in the background.我希望它在后台运行。 I've head of using ajax but alas I have not found an ajax solution in this.我负责使用 ajax,但是我还没有在这方面找到 ajax 解决方案。 Any feedback will be appreciated thank you.任何反馈将不胜感激,谢谢。

This is for a notification.这是一个通知。

How do i call the server by ajax and asking frequently if there's any changes etc.我如何通过 ajax 调用服务器并经常询问是否有任何更改等。

Cron did the job for me after learning it!学习后,Cron 为我完成了这项工作! sorry for the dumb question guys.对不起那些愚蠢的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM