In order to learn debugging we must understand:
* Types of bugs
* The debugging process
* Complex applications (Ajax, RIA, etc.) behavior
* Complex applications moments of interest
* Tools
Types of bugs
* Syntax/parse errors
* Fatal errors, warnings and notices
* Database errors
* Logical errors
Syntax Errors
This is the most common error at development time, luckily most can be avoided using a good editor; the most common causes are:
* Missing ; at the end of the line (The error normally displays on the next line)
* Missing or extra parentheses
* Unclosed braces
* Type errors
* Incorrect string concatenation
Fatal Errors
Fatal errors normally occur in development time and stop PHP from running. Error messages are normally clear and indicate the precise line that causes the error.
Common causes are:
* Extra } in classes
* Calls to non existing classes or functions
Warnings
Errors that doesn't stop PHP but will normally cause problems. Some common causes:
* Incorrect number of parameters
* Not found index in array
* Cannot modify header information
* Session_start - headers already sent
All warnings must be fixed, normally PHP will display which line of code is making the incorrect function call, this is the place to start checking.
If you need to trace the function calls (stack) to detect where the problem occurs you can use debug_print_backtrace() in PHP; in Tequila you can call showcallstack();
Notices
Notices are lighter errors in PHP, sometimes code appear to work properly if you ignore them, but this might just mean code shows a standard behavior but doesn't always mean the developer intended behavior. Good code must not generate a single Notice, common 'Notice' causes are:
* Undeclared variables
* Missing quotes
i.e. $array[key];
// if you mean:
$array['key'];
//it will work as PHP believes it's a constant with value 'key'
// but if you meant
$array[$key];
//it might work but logic is completely wrong, an empty key might be returned
Find php framework and more useful information about RAD workflow open source.
Thứ Hai, 12 tháng 10, 2009
Đăng ký:
Đăng Nhận xét (Atom)

Không có nhận xét nào:
Đăng nhận xét