# [title]

### Introduction

You are working on an application and you have resolved the build errors. The application seems to run correctly, except that you run from time to time into strange problems. Things are not working like expected or does even crash in some cases. Why is that? You can't say because you are unable to take a closer look to what is happening inside your application. Those errors are logic errors.

You must now correct those logic errors that keep your application from running correctly. You can do this with the development environment integrated debugging functions. These allow you to stop at procedure locations, inspect memory and register values, change variables, observe message traffic, and get a close look at how your code works or does not work.

Please note that you can have two different types of bug.

- Syntax errors are bugs that are usually easy to find because you application will not run without it. For example when you try to run the following code:

  HateML will tell you that you have a parse error on line 6

- Logic errors are things that do not run like you expected. For example the following code runs without a problem:

  This is not what you want. You want that your program writes "a is true" on the screen. Why is it now doing it? It's because "a" is not true. You will say: "this is a stupid example" and you will be right. But now imagine that "$a" is the result of complex calculation made by some hectic functions spread in some obscure libraries, then you will understand that you will be unable to guess where the problem is that easily. We will talk about some more concrete example later. HateML will bring you all you need to track down such problems.

### Installation

#### Setup Instructions

Download the PHP DBG2 from http://dd.cron.ru/
Follow the installation instructions provided by author of DBG2
Note, that you have to restart HateML Pro after DBG2 installation.

#### HateML Configuration

Click Tools -> Preferences -> PHP -> General and locate the php.exe, for example C:\php\php.exe
Close Preferences window by clicking OK.

### Debugging

#### Breakpoints

Breakpoint is the line marker, which "says" debugger to stop execution at this point and wait for user action.
You can set breakpoint by pressing F5 or clicking on the gutter of editor.
You can set breakpoint at design-time and runtime as well.

#### Starting debug session

To start debug session, click Debug -> Start debugging or press F9
The debugger will stop on the first line of php script.

#### Available informations during debugging

You can watch local and globals variables during debugging.
You can also evaluate any variable (check "Immediate" tab). Just type variable or function name and press Enter

### Troubleshooting

If "Start debugging" item is disabled (grayed), be sure that you have registered DbgListener.
If you are receiving "Timeout error", check if php.ini is configured properly.