Guest User

Untitled

a guest
Mar 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. In browser debugging print_r and vardump is not enough and lots of developers have to each time wrap with <pre>
  2.  
  3. I created and using following function as set globally in bootstrap file and it makes debuggig easier and better readability
  4.  
  5.  
  6. ```
  7. /**
  8. @param $mixed mandatory any data type
  9. @param $die optional , default true
  10. @param $varDump optional , default false
  11. @return preformatted print_r or vardump output
  12. */
  13.  
  14. //you can rename this function as per your convenience ex: _dbg , _debug etc. enjoy debugging
  15.  
  16. function print_pre($mixed,$die=true,$varDump=false){
  17.  
  18. echo '<pre>';
  19. if($varDump)
  20. var_dump($mixed);
  21. else
  22. print_r($mixed);
  23.  
  24. echo '<pre>';
  25.  
  26. if($die)
  27. die('__END__');
  28.  
  29. }
  30.  
  31. ```
Add Comment
Please, Sign In to add comment