Cml\Console\IO\Output::write PHP Method

write() public static method

输出内容
public static write ( string $text, mixed $pipe = STDOUT )
$text string
$pipe mixed
    public static function write($text, $pipe = STDOUT)
    {
        fwrite($pipe, $text);
    }

Usage Example

Example #1
0
 /**
  * 提问并获取用户输入
  *
  * @param string $question 问题
  * @param bool $isHidden 是否要隐藏输入
  * @param string $default 默认答案
  * @param bool $displayDefault 是否显示默认答案
  *
  * @return string
  */
 public function ask($question, $isHidden = false, $default = '', $displayDefault = true)
 {
     if ($displayDefault && !empty($default)) {
         $defaultText = $default;
         if (strlen($defaultText) > 30) {
             $defaultText = substr($default, 0, 30) . '...';
         }
         $question .= " [{$defaultText}]";
     }
     Output::write("{$question} ");
     return $isHidden ? $this->askHidden() : trim(fgets(STDIN)) ?: $default;
 }
All Usage Examples Of Cml\Console\IO\Output::write