note 98642 deleted from features.commandline.interactive by cmb
| From: | cmb@php.net | Date: | Tue, 09 Nov 2021 11:12:22 +0000 |
| Subject: | note 98642 deleted from features.commandline.interactive by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-217163@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
It seems the interactive shell cannot be made to work in WIN environments at the moment.
Using "php://stdin", it shouldn't be too difficult to roll your own. You can
partially mimic the shell by calling this simple script (Note: Window's cmd already has an
input history calling feature using the up/down keys, and that functionality will still be available
during execution here):
<?php
$fp = fopen("php://stdin", "r");
$in = '';
while($in != "quit") {
echo "php> ";
$in=trim(fgets($fp));
eval ($in);
echo "\n";
}
?>
Replace 'eval' with code to parse the input string, validate it using is_callable and
other variable handling functions, catch fatal errors before they happen, allow line-by-line
function defining, etc. Though Readline is not available in Windows, for more tips and examples for
workarounds, see http://www.php.net/manual/en/ref.readline.php