function debug in Drupal 8
Same name and namespace in other branches
- 7 includes/common.inc \debug()
- 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 FALSE to use var_export() instead of print_r(). Passing recursive data structures to var_export() will generate an error.
8 calls to debug()
- AssertPageCacheContextsAndTagsTrait::assertCacheContexts in core/
modules/ system/ src/ Tests/ Cache/ AssertPageCacheContextsAndTagsTrait.php - Ensures that some cache contexts are present in the current response.
- AssertPageCacheContextsAndTagsTrait::assertCacheMaxAge in core/
modules/ system/ src/ Tests/ Cache/ AssertPageCacheContextsAndTagsTrait.php - Asserts the max age header.
- AssertPageCacheContextsAndTagsTrait::debugCacheTags in core/
modules/ system/ src/ Tests/ Cache/ AssertPageCacheContextsAndTagsTrait.php - Provides debug information for cache tags.
- EntityCacheTagsTestBase::verifyRenderCache in core/
modules/ system/ src/ Tests/ Entity/ EntityCacheTagsTestBase.php - Verify that a given render cache entry exists, with the correct cache tags.
- EntityCacheTagsTestBase::verifyRenderCache in core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityCacheTagsTestBase.php - Verify that a given render cache entry exists, with the correct cache tags.
7 string references to 'debug'
- ErrorTest::providerTestGetLastCaller in core/
tests/ Drupal/ Tests/ Core/ Utility/ ErrorTest.php - Data provider for testGetLastCaller.
- PhpUnitTestRunner::summarizeResults in core/
lib/ Drupal/ Core/ Test/ PhpUnitTestRunner.php - Tallies test results per test class.
- PhpUnitTestRunnerTest::providerTestSummarizeResults in core/
tests/ Drupal/ Tests/ Core/ Test/ PhpUnitTestRunnerTest.php - SimpletestDeprecationTest::testDeprecatedPhpUnitFunctions in core/
modules/ simpletest/ tests/ src/ Kernel/ SimpletestDeprecationTest.php - @expectedDeprecation simpletest_phpunit_xml_filepath is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Test\PhpUnitTestRunner::xmlLogFilepath() instead. See https://www.drupal.org/node/2948547 @expectedDeprecation…
- TestBase::error in core/
modules/ simpletest/ src/ TestBase.php - Fire an error assertion.
File
- core/
includes/ common.inc, line 1127 - Common functions that many Drupal modules will need to reference.
Code
function debug($data, $label = NULL, $print_r = TRUE) {
// Print $data contents to string.
$string = Html::escape($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));
}