Science, asked by dishasajjands110, 1 year ago

How to run the interactive PHP shell from the command line interface?

Answers

Answered by AgarwalSahb
0

From PHP: Read from Keyboard – Get User Input from Keyboard Console by Typing:  You need a special file: php://stdin which stands for the standard input. print "Type your message. Type '.' on a line by itself when you're done.\n";  $fp = fopen('php://stdin', 'r'); $last_line = false; $message = ''; while (!$last_line) {     $next_line = fgets($fp, 1024); // read the special file to get the user input from keyboard     if (".\n" == $next_line) {       $last_line = true;     } else {       $message .= $next_line;     } }

Similar questions