It may sound odd, but I’ve been programming games in PHP. The main problem I’ve found was that the only way to update PHP is to load a page. That makes real-time slow. Javascript can interact with a page without reloading it. Is it possible to load PHP pages on a page using Javascript? So that it would allow PHP to be loaded over and over without reloading.
I’ve seen it done with Chat rooms but not sure how it works.
We mostly use Ajax, which consists in a client-side Javascript code that calls a server-side page, with out leaving the page.
Here’s an example that will get the displayed content of a page, using the GET method (JSFiddle):
And here using the POST method (JSFiddle):
Note that here we use the
setRequestHeadermethod to change the headers of this HTTP request and, in this case, to change theContent-typeand theContent-length(this header has a default value of 4096 bytes). Also, thesetRequestHeadermethod must be called after theopenmethod.These links should help you:
https://developer.mozilla.org/en/Ajax
http://code.google.com/intl/pt-BR/edu/ajax/tutorials/ajax-tutorial.html