You are here

function dprint_r in Devel 5

Same name and namespace in other branches
  1. 6 devel.module \dprint_r()
  2. 7 devel.module \dprint_r()

Pretty-print a variable to the browser. Displays only for users with proper permissions. If you want a string returned instead of a print, use the 2nd param.

6 calls to dprint_r()
ddebug_backtrace in ./devel.module
Print the function call stack.
devel_shutdown in ./devel.module
See devel_init() which registers this function as a shutdown function. Displays developer information in the footer.
dpr in ./devel.module
An alias for dprint_r(). Saves carpal tunnel syndrome.
dvm in ./devel.module
Var_dump() a variable to the 'message' area of the page. Uses drupal_set_message()
dvr in ./devel.module
Like dpr, but uses var_dump() instead

... See full list

File

./devel.module, line 1333

Code

function dprint_r($input, $return = FALSE, $name = NULL, $function = 'print_r', $check = TRUE) {
  if (user_access('access devel information')) {
    if ($name) {
      $name .= ' => ';
    }
    ob_start();
    $function($input);
    $output = ob_get_clean();
    if ($check) {
      $output = check_plain($output);
    }
    if (count($input, COUNT_RECURSIVE) > DEVEL_MIN_TEXTAREA) {
      if (has_krumo()) {
        $printed_value = krumo_ob($input);
      }
      else {

        // don't use fapi here because sometimes fapi will not be loaded
        $printed_value = "<textarea rows=30 style=\"width: 100%;\">\n" . $name . $output . '</textarea>';
      }
    }
    else {
      $printed_value = '<pre>' . $name . $output . '</pre>';
    }
    if ($return) {
      return $printed_value;
    }
    else {
      print $printed_value;
    }
  }
}