Created
May 25, 2013 04:55
-
-
Save andriidemus/5647956 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Repl { | |
| protected $promt = "hi"; | |
| protected function readLine() { | |
| print($this->promt . '> '); | |
| if (PHP_OS == 'WINNT') { | |
| $line = stream_get_line(STDIN, 1024, PHP_EOL); | |
| } else { | |
| $line = readline(); | |
| } | |
| return $line; | |
| } | |
| public function run() { | |
| while (($line = $this->readLine()) !== 'exit') { | |
| if (preg_match("/^\//", $line)) { | |
| eval(substr($line, 1) . ";"); | |
| print(PHP_EOL); | |
| } else { | |
| eval("var_dump(" . $line . ");"); | |
| } | |
| } | |
| } | |
| } | |
| $repl = new Repl(); | |
| $repl->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment