PHP Blackjack


This was one of the first programs I ever wrote, and it shows. Among other problems, cards are dealt 'with replacement' so you're very likely to see duplicate cards, and of course card counting does not work. Enjoy the game, but realize ahead of time that this is primarily here as documentation for posterity, not because it's a beacon of good code.

The game shows up inside an iFrame on this page to reduce load times as it refreshes. If you want, you can play the game without this page's formatting and without any frames.

Instructions:

Bet: when you start the game, you have $10,000 in your bank; in order to play, you need to bet a portion of that in the 'Bet' text box. All other boxes are 'read-only' so you cannot change them.

Deal: once you've placed a bet, click 'Deal' and two cards will be dealt to you and the dealer; the dealer's first card will be visible, all others display as asterisks. At this point, your bet will be subtracted from your Bank, and your bet becomes read-only until the end of the hand.

Score: the 'Score' box displays the value of the cards you hold. For those who don't know how to play blackjack, if your score is ever more than 21, you lose. Your score must be higher than the dealer when the round ends.

Hit: deals a new card; play continues.

Stay: ends play; if your score is greater than the dealer's, while 21 or less, twice what you bet is added to your bank.

Double: deals one new card, doubles your bet, and play ends; pays out the same as 'Stay'.

Show: once play has ended, click to see what the dealer had. Note: if you click this during a hand, play ends and your bet is forefit.

And that's that, all you need to know to play the game. If you ever get in a pickle, click 'Reset Game' to reset everything to the way it was when the page first appeared.

Playing Cards from eCardTricks.com