24 lines
No EOL
880 B
PHP
24 lines
No EOL
880 B
PHP
<?php
|
|
|
|
namespace Utils;
|
|
|
|
class Debug {
|
|
|
|
/**
|
|
* Print the contents of a variable with a customizable name and backtrace information.
|
|
*
|
|
* @param mixed $data The variable to print.
|
|
* @param string $name The name to display above the variable contents.
|
|
*
|
|
* @return void
|
|
*/
|
|
static function n_print(mixed $data, string $name = ''): void {
|
|
error_reporting(-1);
|
|
$aBackTrace = debug_backtrace();
|
|
echo '<h2>', $name, '</h2>';
|
|
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
|
|
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">', $aBackTrace[0]['file'], ' ligne => ', $aBackTrace[0]['line'], '</legend>';
|
|
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
|
|
echo '</fieldset><br />';
|
|
}
|
|
} |