在使用drupal7中,我们经常使用debug()这个函数作为调试函数,这是个drupal提供的输出debug信息的函数.
API代码地址:https://api.drupal.org/api/drupal/includes%21common.inc/function/debug/7.x
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 ? "{<span class="php-variable">$label</span>}: {<span class="php-variable">$string</span>}" : $string));
}
这里使用了check_plain()也是drupal7提供的转义HMTL实体的函数。
这里使用了trigger_error()用户级别的错误处理函数来输出结果。
转载于:https://blog.51cto.com/5890945/1977627