Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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