コード例 #1
0
 /**
  * prompts user for input
  * 
  * @param  string $_promptText   prompt text to dipslay
  * @param  bool   $_isPassword  is prompt a password?
  * @return string
  */
 public static function promptInput($_promptText, $_isPassword = FALSE)
 {
     fwrite(STDOUT, PHP_EOL . "{$_promptText}> ");
     if ($_isPassword) {
         if (preg_match('/^win/i', PHP_OS)) {
             $pwObj = new Com('ScriptPW.Password');
             $input = $pwObj->getPassword();
         } else {
             system('stty -echo');
             $input = fgets(STDIN);
             system('stty echo');
         }
         fwrite(STDOUT, PHP_EOL);
     } else {
         $input = fgets(STDIN);
     }
     return rtrim($input);
 }