There is a cli script for PHP. There are data that are entered from the keyboard, it would be desirable to hide them, for example, close the asterisks. At the moment I use the readline function:

$password = readline('Password: '); 

In bash, this is implemented using the read command:

 read -s var 

Is it possible to implement this using php features?

1 answer 1

You can do the following:

 <?php echo 'Password: '; $oldStyle = shell_exec('stty -g'); shell_exec('stty -echo'); $password = rtrim(fgets(STDIN), "\n"); shell_exec('stty ' . $oldStyle); echo "\r\n"; echo $password; echo "\r\n";