Updated: 28 May 2023
Write a variable to the error log with print_r
error_log(print_r($var, true));
Write a variable to the error log via var_dump
function error_log_var_dump( $var ){
ob_start();
var_dump( $var );
$cont = ob_get_contents();
ob_end_clean();
error_log( $cont );
}
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
// Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_LOG', true );
// Display errors and warnings
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 1 );