This project explains states using a game (with normal if statements) and a PHP implementation using the state pattern.
You can see the game here: https://rskuipers.github.com/stateful-elephpant
If you want to run the game locally, start a php service in the root of this project.
$ php -S 0:8080
And view the game here: http://localhost:8080/index.html
You can also execute the PHP equivalant.
$ php index.php