The standard debugging techniques in PHP are echo $variable
, die($variable)
and var_dump($variable)
. These simple debugging tricks don't always work (when you are working with AJAX and JSON) when it is printed in a hidden HTML section.
If you want to do a simple debugging trick without changing the HTML output of a page, you can use the Magento logging. This will write the debugged results to a log file.
We will print some data to the Magento log files. To easily view the content of these files, we need command line access. Also, open your IDE because we will add some logging statements in the Magento code.