Jump to content
  • Advertisement
Sign in to follow this  
Daisy Ontas

How to design tic tac toe in PHP ?

This topic is 1513 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


PHP is for programming the server-side of an application and works with http requests, you need more than PHP to make a game, and the most "gaming" parts of the application will be done in that other language (JavaScript, for example).


With PHP you can store and retrieve information, with JavaScript you draw the game, handle input, all the animations, etc, etc. You could make a game just with JavaScript if you want, but not with PHP alone.


There are a lot of HTML5/JavaScript game engines and frameworks, try any of them: http://html5gameengine.com/


EDIT: For a tic tac toe multiplayer game played from different PC's (I guess you want something like that since PHP will work for the comunication only) you need to have a list of connected users, so you can start a match between 2 of them. Then, in the client side you check the state of the match requesting it to the PHP server. In the server you'll need to store the player who's turn just passed and the move he/she made, so the other player can retrieve that move and can update the board.


You can add more and more complexity, you could store the state of the board in the server instead of just the last move, and get the board on every check, to prevent cheating (javascript code can be edited pretty easily in any browser). Also, if you store the board you may also want to check for the winner in the server after each move, so players can't cheat sending a "I won" message.


EDIT2: Now that I think of it, you could be able to make a multiplayer tic tac toe game without much JavaScript, but with HTML elements, since nothing happens while waiting for the next move, but it'll take more time an effort. You can create a board with a table of buttons, and surround the table with a form. Each button submits the form with a different value so you know where the player "moved", and in PHP you setup the HTML response and reconstruct the board with disabled buttons on the already selected places.

Edited by DiegoSLTS

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!