How to debug php code in hostgator cPanel

PHP errors are the cause of whitescreens. You will have error logs in your Cpanel at Hostgator, but it’s much easier to use the debug logs that are available in WordPress. (For debugging outside of the WordPress environment, see http://php.net/manual/en/debugger-about.php about PHP’s own debugger and third-party debuggers).

And, there are several other debugging methods you should learn when working with WordPress – in order to handle PHP as well as to debug database queries and find/fix Javascript errors – since WordPress (and themes and plugins) use a database as well as Javascript.

PHP

For PHP debugging and finding the , use the built-in WordPress function WP_DEBUG. See https://codex.wordpress.org/WP_DEBUG

Add

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

in wp-config.php and the debug.log file will be in wp-content.

Add this line

define( 'WP_DEBUG_DISPLAY', true);

to wp-config.php to log and dump them to the browser.

See this answer to find out how to change the location of the debug.log file: Is it possible to change the log file location for WP_DEBUG_LOG?

Database queries:

Also look at the plugins https://wordpress.org/plugins/debug-objects/ and https://wordpress.org/plugins/debug-bar/ for help with database queries.
You need to set

define('SAVEQUERIES', true);

in wp-config.php to debug database queries.

Javascript:

For Javascript, you can turn on

define('SCRIPT_DEBUG', true);

too, in wp-config.php.

And be sure and learn how to use the developer tools in Firefox (or Firebug) or Chrome or Safari or IE to work with Javascript as well as HTML and CSS issues.