I am beginner. A useful feature that shows where the print_r is coming from. what do you think? please upgrade if you know better
<?php
// without exit
function pr() {
$trace = debug_backtrace();
$msgTemplate = 'Debug called from %s (line %s) ';
echo '<h3>', sprintf($msgTemplate, $trace[0]['file'], $trace[0]['line']), '<h3>';
$separator = ' ++++++++ DEBUG +++++++ ';
echo '<h2>' . __FUNCTION__ . $separator . '</h2>';
$args = func_num_args();
for ($i = 0; $i < $args; $i++) {
echo '<pre>';
echo print_r(func_get_arg($i), true);
echo '</pre>';
}
echo '<h2>' . __FUNCTION__ . $separator . '</h2>';
}
// with exit
function prx() {
$trace = debug_backtrace();
$msgTemplate = 'Debug called from %s (line %s) ';
echo '<h3>', sprintf($msgTemplate, $trace[0]['file'], $trace[0]['line']), '<h3>';
$separator = ' ++++++++ DEBUG +++++++ ';
echo '<h2>' . __FUNCTION__ . $separator . '</h2>';
$args = func_num_args();
for ($i = 0; $i < $args; $i++) {
echo '<pre>';
echo print_r(func_get_arg($i), true);
echo '</pre>';
}
echo '<h2>' . __FUNCTION__ . $separator . '</h2>';
exit;
}