php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43848 Should be an option to disable echo when reading php://stdin
Submitted: 2008-01-15 04:43 UTC Modified: 2011-03-01 00:47 UTC
Votes:9
Avg. Score:3.9 ± 1.0
Reproduced:6 of 6 (100.0%)
Same Version:4 (66.7%)
Same OS:3 (50.0%)
From: graced at wingsnw dot com Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 5.2.5 OS: Irrelevant
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2008-01-15 04:43 UTC] graced at wingsnw dot com
Description:
------------
Short of using an experimental extension that's not likely to be available on a default install, there appears to be no way to disable/enable echoing of stdin content when reading it.

A use case would be something like:

<?php
ob_implicit_flush(true);
echo "Please enter your password: ";
// code to disable echo here
$password = fgets(STDIN);
// code to re-enable echo here.



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-01 00:39 UTC] jgc at yahoo-inc dot com
Python supports a fxn for the password input use-case:
http://docs.python.org/py3k/library/getpass.html?highlight=password

Equivalent of that would satisfy me.

You can do the equivalent on unixy systems this way, but, alas, doesn't work
on Windows, which many of our CLI script users have:


            $stty = `stty -g`;
            system("stty -echo");
            $input = trim(fgets(STDIN));
            system("stty $stty");
 [2011-03-01 00:47 UTC] rasmus@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2011-03-01 00:47 UTC] rasmus@php.net
This seems beyond what we should be supporting in the core of PHP. I am sure 
there are ways of doing this on Windows. A quick search gets me the 
ScriptPW.Password component. It should be easy enough to trigger that via the 
COM extension.

eg.

$pwd = new Com('ScriptPW.Password');
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 17:01:33 2024 UTC