You are here

function drupal_debug in Devel 5

Same name and namespace in other branches
  1. 6 devel.module \drupal_debug()
  2. 7 devel.module \drupal_debug()
1 call to drupal_debug()
dd in ./devel.module

File

./devel.module, line 1251

Code

function drupal_debug($data, $label = NULL) {
  ob_start();
  print_r($data);
  $string = ob_get_clean();
  if ($label) {
    $out = $label . ': ' . $string;
  }
  else {
    $out = $string;
  }
  $out .= "\n";

  // The temp directory does vary across multiple simpletest instances.
  $file = file_directory_temp() . '/drupal_debug.txt';
  if (file_put_contents($file, $out, FILE_APPEND) === FALSE) {
    drupal_set_message(t('The file could not be written.'), 'error');
    return FALSE;
  }
}