Basic REPL
This commit is contained in:
@@ -1,2 +1,16 @@
|
||||
<?php
|
||||
echo "Hello world of PHP CLI!";
|
||||
|
||||
// Placeholder Globals
|
||||
$userid = 0;
|
||||
$room_lang = "th";
|
||||
$is_admin = false;
|
||||
define("BLUE_ROOM", 12345);
|
||||
define("RED_ROOM", 67890);
|
||||
define("INTER_ROOM", 111213);
|
||||
|
||||
// randomorg($start,$end);
|
||||
|
||||
function reply_user($room_id, $msgid, $message)
|
||||
{
|
||||
return $msgid;
|
||||
}
|
||||
17
src/repl.php
Normal file
17
src/repl.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
require 'entryPoint.php';
|
||||
if(!defined("STDIN")) {
|
||||
define("STDIN", fopen('php://stdin','r'));
|
||||
}
|
||||
|
||||
$room_id = BLUE_ROOM;
|
||||
$msg_id = 0;
|
||||
|
||||
echo "Starting test REPL\n";
|
||||
do {
|
||||
$input = fread(STDIN, 80); // Read up to 80 characters or a newline
|
||||
$trimmed = trim($input);
|
||||
|
||||
echo '> ' , reply_user($room_id, $msg_id, $trimmed) , "\n";
|
||||
$msg_id++;
|
||||
} while($trimmed !== "exit");
|
||||
Reference in New Issue
Block a user