Last active
August 29, 2015 14:16
-
-
Save alexbabintsev/e40629a3973866e5336c to your computer and use it in GitHub Desktop.
Yii2: отладка переменных
This file contains hidden or 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 | |
/** | |
* Debug function | |
* d($var); | |
*/ | |
function d($var,$caller=null) | |
{ | |
if (!isset($caller)){ | |
$caller = array_shift(debug_backtrace(1)); | |
} | |
echo '<code>File: '.$caller['file'].' / Line: '.$caller['line'].'</code>'; | |
echo '<pre>'; | |
yii\helpers\VarDumper::dump($var, 10, true); | |
echo '</pre>'; | |
} | |
/** | |
* Debug function with die() after | |
* dd($var); | |
*/ | |
function dd($var) | |
{ | |
$caller = array_shift(debug_backtrace(1)); | |
d($var,$caller); | |
die(); | |
} |
This file contains hidden or 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
/* Include debug functions */ | |
require_once(__DIR__.'/functions.php'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment