Not an easy thing to do. I have tried it. Turn-based games are possible with Flash/PHP, but trying to make a real-time game (a MMORPG, for example) would be pretty tough. The reason is that Flash has to open an HTTP request each time it talks to the server.
Also, AJAX does not apply here because it is for XHTML/JavaScript/PHP. You're talking about Flash/PHP.
As far as "socket programming" goes, polling with Flash/PHP is one way to go about it. Java is much more suited to what you're trying to do though, because it can maintain a connection between the server and the client.
I don't want to tell you there's no way to do what you're describing with PHP, but you're fighting an uphill battle here.
You may want to check out Adobe AIR, if you wanted to try this as a desktop application (which would be a little easier). AIR uses HTML, JavaScript, and PHP, so you may already know how to write the code required.