Var_dump array contents into LOG

Hi,

Just thought I would drop this here incase it helps anyone. I’ve used it for years and just realized it may be useful to others.

var_dump drops the output onto the screen. This function drops the output into the log file.

Just load the function in Global_Code and call it when ever you want to dump an array. var_sys_log($array);


function var_sys_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

    LOG( $contents );       // log contents of the result of var_dump( $object )

}

Happy coding.

You may also use var_export().

1 Like

Try the new VarDump() function of v2026.