Skip to content

Instantly share code, notes, and snippets.

@PEMapModder
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save PEMapModder/f3e3fe8beb816516845f to your computer and use it in GitHub Desktop.

Select an option

Save PEMapModder/f3e3fe8beb816516845f to your computer and use it in GitHub Desktop.
<?php
require_once("readline.php");
$thread = new ConsoleThread;
$thread->start();
while(true){
sleep(10);
echo "I am still alive!" . PHP_EOL;
}
class ConsoleThread extends Thread{
public function run(){
loopConsole();
}
}
<?php
if(!defined("STDIN")){
define("STDIN", fopen("php://stdin", "rt"));
}
function loopConsole(){
while(true){
$line = trim(fgets(STDIN));
echo $line . PHP_EOL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment