Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
easier and better readability with print_r and vardump for php developers
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
You can’t perform that action at this time.