Skip to content

Instantly share code, notes, and snippets.

@cn0047
Created August 2, 2018 23:10
Show Gist options
  • Save cn0047/94662ff233448fe7edc2d207b9a73e8f to your computer and use it in GitHub Desktop.
Save cn0047/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