Same name and namespace in other branches
  1. 8.9.x core/includes/common.inc \debug()
  2. 9 core/includes/common.inc \debug()

Outputs debug information.

The debug information is passed on to trigger_error() after being converted to a string using _drupal_debug_message().

Parameters

$data: Data to be output.

$label: Label to prefix the data.

$print_r: Flag to switch between print_r() and var_export() for data conversion to string. Set $print_r to TRUE when dealing with a recursive data structure as var_export() will generate an error.

1 call to debug()
SimpleTestFunctionalTest::stubTest in modules/simpletest/simpletest.test
Test to be run and the results confirmed.
5 string references to 'debug'
CommentInterfaceTest::setEnvironment in modules/comment/comment.test
Re-configures the environment, module settings, and user permissions.
DrupalTestCase::error in modules/simpletest/drupal_web_test_case.php
Fire an error assertion.
DrupalWebTestCase::storeSetupCache in modules/simpletest/drupal_web_test_case.php
Store the installation setup to a cache.
watchdog_severity_levels in includes/common.inc
Returns a list of severity levels, as defined in RFC 3164.
_drupal_get_last_caller in includes/errors.inc
Gets the last caller from a backtrace.

File

includes/common.inc, line 7874
Common functions that many Drupal modules will need to reference.

Code

function debug($data, $label = NULL, $print_r = FALSE) {

  // Print $data contents to string.
  $string = check_plain($print_r ? print_r($data, TRUE) : var_export($data, TRUE));

  // Display values with pre-formatting to increase readability.
  $string = '<pre>' . $string . '</pre>';
  trigger_error(trim($label ? "{$label}: {$string}" : $string));
}