/** * Debug function * d($var); * @param $var * @param null $caller */ function d ( $var , $caller = null ) { if ( ! isset ( $caller )){ $tmp_var = debug_backtrace ( 1 ); $caller = array_shift ( $tmp_var ); } header ( 'Content-Type: text/html; charset=utf-8' ); echo '<code>File: ' . $caller [ 'file' ] . ' / Line: ' . $caller [ 'line' ] . '</code>' ; echo '<pre>' ; VarDumper :: dump( $var , 10 , true ); echo '</pre>' ; } /** * Debug function with die() after * dd($var); * @param $var */ function dd2 ( $var ) { $tmp_var = debug_backtrace ( 1 ); $caller = array_shift ( $tmp_var ); $this -> d( $var , $caller ); die (); } https://github.com/samdark/yii2-cookbook/blob/master/book/structure-global-...