How to debug php code in hostgator cPanel

admin2025-06-06  2

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.

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.

Share Improve this question edited Aug 28, 2016 at 19:10 markratledge 8,7356 gold badges40 silver badges62 bronze badges asked Aug 28, 2016 at 18:32 arqamarqam 1231 silver badge7 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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/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/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/plugins/debug-objects/ and https://wordpress/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.

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749154018a316825.html

最新回复(0)