Password prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| public function insilent() | |
| { | |
| $oldStyle = shell_exec('stty -g'); | |
| shell_exec('stty -echo'); | |
| $value = $this->stdin->fgets(); | |
| shell_exec('stty ' . $oldStyle); | |
| return $value; | |
| } | |
| // Here's a Windows solution, using the COM extension for PHP. I tested this on Windows XP with PHP 5.2.6. | |
| $pwObj = new Com('ScriptPW.Password'); | |
| print "Password: "; | |
| $passwd = $pwObj->getPassword(); | |
| echo "Your password is $passwd\n"; | |
| // http://stackoverflow.com/questions/297850/is-it-really-not-possible-to-write-a-php-cli-password-prompt-that-hides-the-pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment