function drush_print

8.0.x drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE)
6.x drush_print($message = '', $indent = , $handle = NULL, $newline = TRUE)
7.x drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE)
3.x drush_print($message = '', $indent = 0)
master drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE)

Prints a message with optional indentation. In general, drush_log($message, LogLevel::OK) is often a better choice than this function. That gets your confirmation message (for example) into the logs for this drush request. Consider that drush requests may be executed remotely and non interactively.


$message: The message to print.

$indent: The indentation (space chars)

$handle: File handle to write to. NULL will write to standard output, STDERR will write to the standard error. See

$newline: Add a "\n" to the end of the output. Defaults to TRUE.

Related topics

64 calls to drush_print()
druplicon_drush_exit in commands/core/
Implements hook_drush_exit().
drush_choice in includes/
Ask the user to select an item from a list. From a provided associative array, drush_choice will display all of the questions, numbered from 1 to N, and return the item the user selected. "0" is always cancel; entering a blank line is also…
drush_config_edit in commands/core/
Edit command callback.
drush_config_import in commands/core/
Command callback. Import from specified config directory (defaults to sync).
drush_confirm in includes/
Asks the user a basic yes/no question.

... See full list


includes/, line 28


function drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE) {
  $msg = str_repeat(' ', $indent) . (string) $message;
  if ($newline) {
    $msg .= "\n";
  if (($charset = drush_get_option('output_charset')) && function_exists('iconv')) {
    $msg = iconv('UTF-8', $charset, $msg);
  if (isset($handle)) {
    fwrite($handle, $msg);
  else {
    print $msg;