23 lines
986 B
PHP
23 lines
986 B
PHP
<?php
|
|
|
|
namespace App\Utils;
|
|
|
|
class Debug {
|
|
/**
|
|
* Outputs a formatted representation of the provided data, along with the file name and line number
|
|
* where the function was called.
|
|
*
|
|
* @param mixed $data The data to be printed, can be of any type.
|
|
* @param string $name An optional name to display as a header for the output. Defaults to an empty string.
|
|
* @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 />';
|
|
}
|
|
}
|