Skip to content
AgileLogics
4 min read

Debugging Basics

Prerequisites: Comments & code style

Turn on full error reporting during development — by default, some notices/warnings are silenced, hiding real bugs:

error_reporting(E_ALL);
ini_set('display_errors', '1');

var_dump() shows a value's type and content precisely; print_r() is more readable for a quick look at an array; both beat guessing:

var_dump($user);   // object(User)#1 (2) { ["name"]=> string(3) "Ada" ... }
print_r($user);    // User Object ( [name] => Ada ... )

Common mistakes

  • Leaving display_errors on in production — this can leak file paths and other internals to visitors. Log errors instead (covered in Level 2).