Created
May 19, 2020 22:03
-
-
Save jacobmc/38f87b97567bb9462777cc804c5e3bd4 to your computer and use it in GitHub Desktop.
Function for dumping data to the error log. Courtesy of Justin Silver (https://www.justinsilver.com/technology/writing-to-the-php-error_log-with-var_dump-and-print_r/)
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
function var_error_log( $object=null ){ | |
ob_start(); // start buffer capture | |
var_dump( $object ); // dump the values | |
$contents = ob_get_contents(); // put the buffer into a variable | |
ob_end_clean(); // end capture | |
error_log( $contents ); // log contents of the result of var_dump( $object ) | |
} | |
$object = new MyObject(); | |
var_error_log( $object ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment