If you're thinking "surely PHP isn't up to coping with this kind of rapid client/server request strain?", think again about how those search as you type autocomplete text field/dropdown UI components work on most webites, UI components which strain the server far more than simple chat real-time gaming requirements would.
Below is a simple basic working example. Open up multiple browser tabs/windows of this page on your desktop and/or mobile device to have a chat with yourself or others. Chat logs are reset on the hour.
The client-side code on this page can be View Source'd. The PHP code for awrealtimeserver.php is (it requires a sub-folder called log):
This is very basic code, definitely not production worthy with little error checking or optimisation, but it is presented in this simple form for easier understanding and learning purposes, even though this is not a tutorial!
Moving forward, this approach could be used in VR projects (multiple users represented as avatars in a VR world, e.g. audience for VR Music Videos), and for web games.