标签: php server-sent-events
以下代码每秒向浏览器发送一次更新:
<?php header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); $time = date('r'); echo "data: The server time is: {$time}\n\n"; flush(); ?>
如果文件或数据库的内容发生变化,我怎么能让服务器向浏览器发送更新?