title: Stopping while waiting for user input
body: <p>I'm making a game. In the game, the player and enemies are stored inside objects.
  Each object has properties such as:</p>
  
  <pre><code>$player-&gt;health
  $player-&gt;attack  (this is a value, as in attack power)
  </code></pre>
  
  <p>Then there's the php function which handles the fight:</p>
  
  <pre><code>function fight($player, $enemy) {...}
  </code></pre>
  
  <p>it uses functions like <code>attack($player, $enemy)</code> and <code>castSpell($player,$enemy)</code>.</p>
  
  <p>Now, here is the problem: the game runs on a round system, the player and the enemy each has their turn. What I want is that every time it's the player's turn, the script will wait until the user clicks, and then a function is called according to the button pushed.</p>
  
  <p>I was thinking of using Javascript setTimeout and then stopping it when the user clicks, but as all the objects and functions I use are in php.</p>
  
  <p>How can I do this otherwise?</p>