Created
March 12, 2018 08:29
-
-
Save akwatra/b6a2f21b33e7a86d148618d8a83276b0 to your computer and use it in GitHub Desktop.
easier and better readability with print_r and vardump for php developers
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
In browser debugging print_r and vardump is not enough and lots of developers have to each time wrap with <pre> | |
I created and using following function as set globally in bootstrap file and it makes debuggig easier and better readability | |
``` | |
/** | |
@param $mixed mandatory any data type | |
@param $die optional , default true | |
@param $varDump optional , default false | |
@return preformatted print_r or vardump output | |
*/ | |
//you can rename this function as per your convenience ex: _dbg , _debug etc. enjoy debugging | |
function print_pre($mixed,$die=true,$varDump=false){ | |
echo '<pre>'; | |
if($varDump) | |
var_dump($mixed); | |
else | |
print_r($mixed); | |
echo '<pre>'; | |
if($die) | |
die('__END__'); | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment