简体   繁体   中英

How to debug PHP in the MAMP?

I'm using MAMP on Windows to start a web server for my WordPress website. I want to debug some PHP code (at least write variable values to log/browser console/anywhere else). I've tried to write in PHP source this:

debug_to_console($args);
var_dump($args);
error_log(print_r($args,true));

And looked for the result in MAMP/logs/phperror.log. But it doesn't write anything.

How to debug PHP code in this case?

If you want to debug WordPress, just turn on debug mode . Add this into your wp-config file instead of this one define( 'WP_DEBUG', false );

Add this code:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Next step is just using this one:

error_log(print_r($args,true));

Your $args you'll see in the {your-local-website-path}/wp-content/debug.log file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM