Re: Re: getpass() wrapper
| From: | Edin Kadribasic | Date: | Tue, 20 Mar 2007 19:38:35 +0000 |
| Subject: | Re: Re: getpass() wrapper | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-28494@lists.php.net to get a copy of this message | ||
If you just want to enter password on a Unix-like system you could use the following:
<?php
function get_password($prompt)
{
$ostty =
stty -g;
system(
"stty -echo -icanon min 1 time 0 2>/dev/null || " .
"stty -echo cbreak"
);
echo "$prompt: ";
// Get rid of newline when reading stdin
$r = substr(fgets(STDIN), 0, -1);
echo "\n";
system ("stty $ostty");
return $r;
}
$p = get_password("Password");
echo "Pasword entered: $p\n";
?>
Edin