Skip to content

Instantly share code, notes, and snippets.

@bayleedev
Created July 7, 2014 17:53
Show Gist options
  • Save bayleedev/68c86bb1874f05a509db to your computer and use it in GitHub Desktop.
Save bayleedev/68c86bb1874f05a509db to your computer and use it in GitHub Desktop.
A simple php repl.
<?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