xdebug and Eclipse
xdebug is an immensely powerful tool for exploring what your code really does.
You can get a long way using print_r but ultimately this always requires that you predict the path your code will take - and the tricky bit about debugging is you need it when your predications have gone wrong.
It’s generally pretty easy to set up