1

I have installed wordpress in the hostgator service, but I need to write php scripts and when I run the php code if there is any error it just shows the page is not responding.

So how can I debug my code, as in to know where my error is. I searched all over Internet but could not find any solution.

I don't want to install any lamp or wamp server. I just have to write a few php scripts which might require me to debug.

Please help.

2 Answers 2

4

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.

2
1

Okay I searched a lot and there seems to be a lot of problem in making a change in the setting if you have a shared server.

So the best thing to do is add a php code debugger extenstion in your chrome.

I used this and it works perfectly : PHP Console

But do tell me if anyone find the correct approach for the question. Till then this works perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.