PHP var_dump() to error log

Nice function to var_dump() any variable into php error_log()…
Sometimes it can be very usefull for debugging purposes.

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 )
}

var_error_log( $var );

Credit goes to: justinsilver.com