public function getMaskedInput($prompt = "Enter Password:") {

		$isWin = preg_match('/^win/i', PHP_OS);

		if($isWin){

		    $vbscript = sys_get_temp_dir() . 'prompt_password.vbs';

		    file_put_contents($vbscript, implode(" ", array(
		    		
	    		'wscript.echo(InputBox("',
	      		addslashes($prompt),
	      		'", "", "password here"))'
	      	)));

		    $command = "cscript //nologo " . escapeshellarg($vbscript);
		    $password = rtrim(shell_exec($command));
		    unlink($vbscript);

		    return $password;
	  	} 
	  	
	  	// Else check for Linux
	    $command = "/usr/bin/env bash -c 'echo OK'";
	    if (rtrim(shell_exec($command)) !== 'OK') {

			trigger_error("Can't invoke bash");
			return;
	    }

	    $command = implode(" ", array(

			"/usr/bin/env bash -c 'read -s -p \"",
			addslashes($prompt),
			"\" mypassword && echo \$mypassword'"
		));

	    $password = rtrim(shell_exec($command));
	    echo "\n";
	    
	    return $password;
	}
public function getMaskedInput($prompt = "Enter Password:") {

		$isWin = preg_match('/^win/i', PHP_OS);

		if($isWin){

		    $vbscript = sys_get_temp_dir() . 'prompt_password.vbs';

		    file_put_contents($vbscript, implode(" ", array(
		    		
	    		'wscript.echo(InputBox("',
	      		addslashes($prompt),
	      		'", "", "password here"))'
	      	)));

		    $command = "cscript //nologo " . escapeshellarg($vbscript);
		    $password = rtrim(shell_exec($command));
		    unlink($vbscript);

		    return $password;
	  	} 
	  	
	  	// Else check for Linux
	    $command = "/usr/bin/env bash -c 'echo OK'";
	    if (rtrim(shell_exec($command)) !== 'OK') {

			trigger_error("Can't invoke bash");
			return;
	    }

	    $command = implode(" ", array(

			"/usr/bin/env bash -c 'read -s -p \"",
			addslashes($prompt),
			"\" mypassword && echo \$mypassword'"
		));

	    $password = rtrim(shell_exec($command));
	    echo "\n";
	    
	    return $password;
	}
public function getMaskedInput ( $ prompt = "Enter Password:" ) { $ isWin = preg_match ( '/^win/i' , PHP_OS ) ; if ( $ isWin ) { $ vbscript = sys_get_temp_dir ( ) . 'prompt_password.vbs' ; file_put_contents ( $ vbscript , implode ( " " , array ( 'wscript.echo(InputBox("' , addslashes ( $ prompt ) , '", "", "password here"))' ) ) ) ; $ command = "cscript //nologo " . escapeshellarg ( $ vbscript ) ; $ password = rtrim ( shell_exec ( $ command ) ) ; unlink ( $ vbscript ) ; return $ password ; } // Else check for Linux $ command = "/usr/bin/env bash -c 'echo OK'" ; if ( rtrim ( shell_exec ( $ command ) ) !== 'OK' ) { trigger_error ( "Can't invoke bash" ) ; return ; } $ command = implode ( " " , array ( "/usr/bin/env bash -c 'read -s -p \"" , addslashes ( $ prompt ) , "\" mypassword && echo \$mypassword'" ) ) ; $ password = rtrim ( shell_exec ( $ command ) ) ; echo "\n" ; return $ password ; }
MaskedInput by Troels Knak-Nielsen - sitepoint

Interactively prompts for input without echoing to the terminal.
Requires a bash shell or Windows and won't work with
safe_mode settings (Uses `shell_exec`)

@param string $prompt

@return string
MaskedInput by Troels Knak - Nielsen - sitepoint