How to debug your code

From Joomla! Documentation

Revision as of 06:05, 11 June 2008 by DMn1c (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The simplest way for debug your code is create echo items for variables and output it into the screen. For expample, you want to now what value of the index item in for cycle:

for ( $i = 0; $i < 10; $i++ ) { if ( $i == 5 ) { echo $i; } }

But this way is to hard for debug real code with more than 1000 lines of code. For this perpose better use debuggers plugged into the editors. For example it is PHP Expert editor with installed extension

add lines to the php.ini file:

extension=php_dbg.dll [Debugger] debugger.enabled=on debugger.profiler_enabled=off

profiler_enable better set to off, it is very deceleration option

Than you need set options in menu Run/Options menu to use HTTP-server and directory where your script located.

If all options are correct you may run you script in debug mode by clicking on the Debug button (F8)