You are here

function development_environment_var_dump in Development Environment 7

Dumps the details of a variable.

Parameters

mixed $var: The variable for which details should be dumped.

bool $return: Whether or not to return the data to the calling function. If FALSE, the data is dumped to the screen.

bool $html: Whether or not the outputted data should be an HTML output, or plaintext.

int $level: The depth of $var that should be dumped. Set to 0 (zero) for full depth.

Return value

array|null An array containing the dumped data if $return is set to TRUE, or NULL otherwise.

1 call to development_environment_var_dump()
development_environment_supressed_email_log_page in includes/development_environment.pages.inc
Page definition showing the log data for a single suppressed email.

File

includes/development_environment.pages.inc, line 177
Holds menu callbacks for pages created by the Development Environment module.

Code

function development_environment_var_dump($var, $return = FALSE, $html = FALSE, $level = 0) {
  $spaces = "";
  $space = $html ? " " : " ";
  $newline = $html ? "<br />" : "\n";
  for ($i = 1; $i <= 4; $i++) {
    $spaces .= $space;
  }
  $tabs = $spaces;
  for ($i = 1; $i <= $level; $i++) {
    $tabs .= $spaces;
  }
  if (is_array($var)) {
    $title = "Array";
  }
  elseif (is_object($var)) {
    $title = get_class($var) . " Object";
  }
  $output = $title . $newline . $newline;
  foreach ($var as $key => $value) {
    if (is_array($value) || is_object($value)) {
      $level++;
      $value = development_environment_var_dump($value, TRUE, $html, $level);
      $level--;
    }
    $output .= $tabs . "[" . $key . "] => " . $value . $newline;
  }
  if ($return) {
    return $output;
  }
  else {
    echo $output;
  }
}