in reply to TicTacToe Code Help.

I can reproduce your issue on the unix command line. To figure out what is happening, comment out this line:
# cls();

You clear the screen too soon. You should store the results in a variable, then print after the cls.

Also, the game continues even if someone wins. You need an exit condition.

I got a draw with this sequence: 123465798

See also: Basic debugging checklist

Check out Conditional Operator for assigning to $player.