demos/hangman/protected/controllers/GameController.php
protected function guess($letter)
	{
		$word=$this->word;
		$guessWord=$this->guessWord;
		$pos=0;
		$success=false;
		while(($pos=strpos($word,$letter,$pos))!==false)
		{
			$guessWord[$pos]=$letter;
			$success=true;
			$pos++;
		}
		if($success)
		{
			$this->guessWord=$guessWord;
			if($guessWord===$word)
				return true;
		}
		else
		{
			$this->misses++;
			if($this->misses>=$this->level)
				return false;
		}
	}
protected function guess($letter)
	{
		$word=$this->word;
		$guessWord=$this->guessWord;
		$pos=0;
		$success=false;
		while(($pos=strpos($word,$letter,$pos))!==false)
		{
			$guessWord[$pos]=$letter;
			$success=true;
			$pos++;
		}
		if($success)
		{
			$this->guessWord=$guessWord;
			if($guessWord===$word)
				return true;
		}
		else
		{
			$this->misses++;
			if($this->misses>=$this->level)
				return false;
		}
	}
protected function guess ( $ letter ) { $ word = $ this -> word ; $ guessWord = $ this -> guessWord ; $ pos = 0 ; $ success = false ; while ( ( $ pos = strpos ( $ word , $ letter , $ pos ) ) !== false ) { $ guessWord [ $ pos ] = $ letter ; $ success = true ; $ pos ++ ; } if ( $ success ) { $ this -> guessWord = $ guessWord ; if ( $ guessWord === $ word ) return true ; } else { $ this -> misses ++ ; if ( $ this -> misses >= $ this -> level ) return false ; } }
Checks to see if a letter is guessed correctly.
@param string the letter
@return mixed true if the word is guessed correctly, false
if the user has used up all guesses and the word is guessed
incorrectly, and null if the letter is guessed correctly but
the whole word is guessed correctly yet.
Checks to see if a letter is guessed correctly .