# How to check if debug is true and can I use it for my own code? [duplicate]

This question is an exact duplicate of:

I'm needing to debug one of my themes and I want to be able to switch on a debug mode so I can output more information or switch off debug mode and not see any information.

I noticed there is a debug variable defined in wp_config.php. I can easily set this to true or false. Is it OK to use this variable for my own debugging purposes or should I create my own?

Also, how do I check for if debug is true? My PHP is a bit rusty. Is this correct:

define('WP_DEBUG', true);

if ($WP_DEBUG) { // do something }  My question is different. ## marked as duplicate by Howdy_McGee♦, Mayeenul Islam, Nicolai, cybmeta, Pieter GoosenNov 24 '15 at 17:43 This question was marked as an exact duplicate of an existing question. • Why cant you install your theme on a local instance and leave debug equal to true? Its not a good idea to leave debug true on a live site. – DᴀʀᴛʜVᴀᴅᴇʀ Nov 11 '15 at 2:43 • @Darth_Vader It's much easier for me to debug on the remote site right now. At a later time I might setup a local install. But as you confirmed, it's not a good idea to leave debug set to true on a live site. So I want to enable it briefly to inspect any errors and then turn it off quickly if I have to. Local installs are unfortunately different than remote. – 1.21 gigawatts Nov 11 '15 at 2:47 • @Howdy_McGee not quite the same question. they mention log files and different variables than I am asking about. – 1.21 gigawatts Nov 11 '15 at 2:49 • I wouldn't suggest doing this but if you do you should do a redirect before enabling debug – DᴀʀᴛʜVᴀᴅᴇʀ Nov 11 '15 at 2:56 • WP_DEBUG is defined as a constant, not as a variable, to check it you should do if ( WP_DEBUG ) (without the$ symbol). Apart from that, the linked question by @Howdy_McGee seems what you need to switch on/off debug programmatically. – cybmeta Nov 24 '15 at 9:44

PHP constants don't have the leading \$. Strictly, this isn't WordPress, but since there isn't a Core is_debug() function that I am aware of, what you want is:
if (defined('WP_DEBUG') && true === WP_DEBUG) {

• I'm using if ( WP_DEBUG ) { } and it works just fine... – dev_masta Mar 30 '16 at 23:40