Cake\Console\ConsoleOutput::write PHP Метод

write() публичный Метод

Outputs a single or multiple messages to stdout or stderr. If no parameters are passed, outputs just a newline.
public write ( string | array $message, integer $newlines = 1 ) : integer | boolean
$message string | array A string or an array of strings to output
$newlines integer Number of newlines to append
Результат integer | boolean The number of bytes returned from writing to output.
    public function write($message, $newlines = 1)
    {
        if (is_array($message)) {
            $message = implode(static::LF, $message);
        }
        return $this->_write($this->styleText($message . str_repeat(static::LF, $newlines)));
    }

Usage Example

Пример #1
0
 /**
  * Prompts the user for input, and returns it.
  *
  * @param string $prompt Prompt text.
  * @param string|null $options String of options. Pass null to omit.
  * @param string|null $default Default input value. Pass null to omit.
  * @return string Either the default value, or the user-provided input.
  */
 protected function _getInput($prompt, $options, $default)
 {
     $optionsText = '';
     if (isset($options)) {
         $optionsText = " {$options} ";
     }
     $defaultText = '';
     if ($default !== null) {
         $defaultText = "[{$default}] ";
     }
     $this->_out->write('<question>' . $prompt . "</question>{$optionsText}\n{$defaultText}> ", 0);
     $result = $this->_in->read();
     $result = trim($result);
     if ($default !== null && ($result === '' || $result === null)) {
         return $default;
     }
     return $result;
 }
All Usage Examples Of Cake\Console\ConsoleOutput::write