update
This commit is contained in:
32
application/helpers/debug_helper.php
Normal file
32
application/helpers/debug_helper.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
if (!function_exists('dbg')) {
|
||||
// Affiche une boîte fixe en haut de page. $exit=true pour stopper.
|
||||
function dbg($var, $label = 'DBG', $exit = false)
|
||||
{
|
||||
echo "<pre style='z-index:99999;position:fixed;top:0;left:0;right:0;
|
||||
max-height:40vh;overflow:auto;background:#111;color:#0f0;
|
||||
padding:10px;margin:0;border-bottom:2px solid #0f0'>";
|
||||
echo htmlspecialchars($label, ENT_QUOTES, 'UTF-8'), "\n";
|
||||
print_r($var);
|
||||
echo "</pre>";
|
||||
if ($exit) exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('dd')) {
|
||||
// dump + die
|
||||
function dd($var, $label = 'DD')
|
||||
{
|
||||
dbg($var, $label, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('console_log')) {
|
||||
// Écrit dans la console Chrome via <script>
|
||||
function console_log($var, $label = 'DBG')
|
||||
{
|
||||
echo "<script>console.log(" . json_encode([$label => $var], JSON_UNESCAPED_UNICODE) . ");</script>";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user