Last active
November 14, 2017 18:51
-
-
Save Sirpyerre/e3fffe191cef9cc28ec0b6cc2b057691 to your computer and use it in GitHub Desktop.
Una función para debuguear el contenido de una variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dd( $array = array(),$message = '', $exit = true) | |
{ | |
$trace = debug_backtrace(); | |
$file = isset($trace[0]['file']) ? $trace[0]['file'] : 'Unknow'; | |
$line = isset($trace[0]['line']) ? $trace[0]['line'] : 'Unknow'; | |
$class = isset($trace[1]['class']) ? $trace[1]['class'] : ''; | |
$function = isset($trace[1]['function']) ? $trace[1]['function'] : ''; | |
if (is_array($array)) { | |
echo '<pre>*************<b>' . $message . '</b>***************<br>'; | |
echo '<p style="color:red">'; | |
print_r($array); | |
echo '</p>'; | |
echo '</pre>'; | |
if (!empty($class)) { | |
echo '=========> ' . $class . '::' . $function . '<=========<br>'; | |
} | |
} else if (is_object($array)) { | |
echo "=========> $message <========="; | |
var_dump($array); | |
echo " <========="; | |
if (!empty($class)) { | |
echo '=========> ' . $class . '::' . $function . '<=========<br>'; | |
} | |
} else { | |
echo "=========> $message <========="; | |
var_dump($array); | |
echo " <========="; | |
} | |
echo 'Line[' . $line . '], in file ' . $file .'<=========<br>'; | |
if ($exit) { | |
exit(); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment