How to debug code in WordPress?

How to debug code in WordPress?

When you are writing some plugins and themes for WordPress, and finding it hard to debug because somehow by the time the page has loaded, $_GET, $_POST and $_REQUEST are all empty. Even with error reporting set on, You have not getting error messages either other than...