Skip to content

Instantly share code, notes, and snippets.

@Integralist
Created September 1, 2011 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Integralist/1186135 to your computer and use it in GitHub Desktop.
Save Integralist/1186135 to your computer and use it in GitHub Desktop.
Example PHP code for setting up server-sent events
<?php
header("Content-Type: text/event-stream");
while(true) {
echo "Event: server-time\n";
$time = time();
echo "data: $time\n";
echo "\n";
flush();
sleep(3);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment