Created
July 7, 2014 17:53
-
-
Save bayleedev/68c86bb1874f05a509db to your computer and use it in GitHub Desktop.
A simple php repl.
This file contains 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 { | |
public function run() { | |
while (true) { | |
echo '>> '; | |
echo eval($this->input()) . PHP_EOL; | |
} | |
} | |
public function input() { | |
$input = trim(fgets(STDIN)); | |
// Append semicolon if one does not exist. | |
if (substr($input, -1) !== ';') { | |
$input .= ';'; | |
} | |
return $input; | |
} | |
} | |
$repl = new Repl(); | |
$repl->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment