In the discussion of the chat application's design, we explained why the web-based clients must poll the server for new chat events. Since PHP scripts are only executed in the context of HTTP requests, a simplistic implementation of a chat client would require the user to manually refresh the web page in order to view the latest chat messages. In other words, the PHP script only polls for new updates whenever the user actively requests it. A better solution (the one used by our chat client) uses Ajax to check for new events without requiring any action by the user.
The PHP script running in the web server formats the chat updates using JSON. The following PHP code summarizes the script's activities:
If you would like to see the PHP client in action, you can use ZeroC's live chat server.