-
Notifications
You must be signed in to change notification settings - Fork 7
8. Debug
Yurii Pavlov edited this page Jun 25, 2019
·
5 revisions
You can use special debug functions wp_dump()
and wlog()
to debug your code.
Supports a variable number of arguments
wp_dump( ...$params );
for example:
wp_dump($a, $b, $c);
will display value of all variables in a convenient way with <pre></pre>
array(3) {
[0]=>
string(3) "var $a value"
[1]=>
string(3) "var $b value"
[2]=>
string(3) "var $c value"
}
Writes data to w.log
file, that appears in path get_stylesheet_directory() . '/w.log';
wlog( $var, $desc = ' >> ', $clear_log = false );
You can use it with any type of data. For example:
wlog( ['some string', 55, ['some array with data']], '>> My debug note' );
will add to w.log
:
[14:11:09]-------------------------
[14:11:09]>> My debug note : Array
(
[0] => some string
[1] => 55
[2] => Array
(
[0] => some array with data
)
)