In my own system, I have a
PHP page which displays all the goods I have sold through my online webshops, from the latest transaction to the first.
I would like this page to automatically update, whenever people buy something from me.
I could make
AJAX call every 5 seconds to check the orders in my databases, but that seems 1980?
or is it that way people do it?
How can I go about pushing a notification to my
php page whenever my php newOrder() function (lets call it that) is called?
You can achieve push within PHP but it won't be the most efficient solution because to achieve push you need to maintain long running connections between your client and your server (HTTP or WebSocket connections).
General best practice when building a realtime infrastructure has been to decouple the push solution from your web application (Note: node.js and socket.io has changed this a bit, but personally I still think it should be decoupled). But, assuming that the latter is still the best solution you would need to write/host/install this push solution. Decoupling also means that the technology doesn't have to be PHP but you can access/use it from PHP. Maybe a bit of overkill? And especially if you don't have too many users on your site?
If you'd like to investigate the alternatives or some of the technologies I've mentioned above I'm maintaining a list of realtime technologies which you might also be interested in.