Skip to content

Instantly share code, notes, and snippets.

@cn007b
Created August 2, 2018 23:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cn007b/94662ff233448fe7edc2d207b9a73e8f to your computer and use it in GitHub Desktop.
Save cn007b/94662ff233448fe7edc2d207b9a73e8f to your computer and use it in GitHub Desktop.
Super simple PHP WebSocket example - websockets.html
<html>
<body>
<div id="root"></div>
<script>
var host = 'ws://0.0.0.0:12345/websockets.php';
var socket = new WebSocket(host);
socket.onmessage = function(e) {
document.getElementById('root').innerHTML = e.data;
};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment