Skip to content

Instantly share code, notes, and snippets.

@akwatra
Created March 12, 2018 08:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akwatra/b6a2f21b33e7a86d148618d8a83276b0 to your computer and use it in GitHub Desktop.
Save akwatra/b6a2f21b33e7a86d148618d8a83276b0 to your computer and use it in GitHub Desktop.
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